Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE on undocumented_unsafe_blocks lint #7979

Closed
pymongo opened this issue Nov 16, 2021 · 4 comments · Fixed by #7988
Closed

ICE on undocumented_unsafe_blocks lint #7979

pymongo opened this issue Nov 16, 2021 · 4 comments · Fixed by #7988
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@pymongo
Copy link

pymongo commented Nov 16, 2021

73 ~     // Safety: ...
74 +     unsafe {
   |

thread 'rustc' panicked at 'internal error: entered unreachable code: attempted to remap an already remapped filename', compiler/rustc_span/src/source_map.rs:1107:34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.58 (891ca5f 2021-11-15)

query stack during panic:
#0 [analysis] running analysis passes on this crate

step to reproduce

  1. git clone https://github.com/pymongo/leetcode-rust
  2. git checkout 5432649be7c7fb82e24c5eac83585fe4936e1b77
  3. cargo clippy

Meta

Rust version (rustc -Vv):

rustc 1.58.0-nightly (891ca5f63 2021-11-15)
binary: rustc
commit-hash: 891ca5f63c3b3cfe3939710a728671243e881ed6
commit-date: 2021-11-15
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0

If I apply some // Safety: ... line to solve undocumented_unsafe_blocks lint, then cause another ICE panic

    Checking leetcode-rust v0.1.1 (/home/w/repos/my_repos/leetcode-rust)
thread 'rustc' panicked at 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1677:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.58 (891ca5f 2021-11-15)
@pymongo pymongo added the C-bug Category: Clippy is not doing the correct thing label Nov 16, 2021
@pymongo
Copy link
Author

pymongo commented Nov 16, 2021

@rustbot label +I-ICE

@rustbot rustbot added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 16, 2021
@pymongo
Copy link
Author

pymongo commented Nov 16, 2021

I am trying to find a minimal reproduce code, but when I copy some unsafe code from my leetcode-rust repo to a single file cargo project, then this ICE was not reproduce. So I think currenly the only way to reproduce this bug/ICE is to clone my leetcode-rust repo

@hellow554
Copy link
Contributor

Here's the MCVE:

#![warn(clippy::restriction)]

pub fn print_binary_tree() {
    println!("{}", unsafe {
        String::from_utf8_unchecked(vec![])
    });
}

@hellow554
Copy link
Contributor

Judging from the backtrace it is probably this line:

let source_file = source_map.get_source_file(&file_name)?;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants