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 with clippy::undocumented_unsafe_blocks #7934

Closed
calebzulawski opened this issue Nov 5, 2021 · 4 comments · Fixed by #7945
Closed

ICE with clippy::undocumented_unsafe_blocks #7934

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

Comments

@calebzulawski
Copy link
Member

calebzulawski commented Nov 5, 2021

Code

I couldn't figure out how to reduce this (simple examples pass), but this occurs when running clippy on Portable SIMD (https://github.com/rust-lang/portable-simd, check out the feature/safety branch) after enabling this lint. I'm pretty sure it has something to do with macros.

Meta

Rust version (rustc -Vv):

cargo 1.58.0-nightly (94ca096af 2021-10-29)
release: 1.58.0
commit-hash: 94ca096afbf25f670e76e07dca754fcfe27134be
commit-date: 2021-10-29
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.79.1-DEV (sys:0.4.49+curl-7.79.1 vendored ssl:OpenSSL/1.1.1l)
os: Ubuntu 20.04 (focal) [64-bit]

Clippy version from master: clippy 0.1.58 (84a4ab7f3 2021-11-04)

Error output

thread 'rustc' panicked at 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1682: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 (84a4ab7f3 2021-11-04)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `core_simd`
Backtrace


thread 'rustc' panicked at 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1682:9
stack backtrace:
 0: rust_begin_unwind
           at /rustc/baba6687df3e83fdb15cc6ec239b4a1c75a30505/library/std/src/panicking.rs:498:5
 1: core::panicking::panic_fmt
           at /rustc/baba6687df3e83fdb15cc6ec239b4a1c75a30505/library/core/src/panicking.rs:106:14
 2: core::panicking::panic
           at /rustc/baba6687df3e83fdb15cc6ec239b4a1c75a30505/library/core/src/panicking.rs:47:5
 3: <rustc_span::SourceFile>::lookup_file_pos_with_col_display
 4: clippy_lints::undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::block_has_safety_comment
           at /home/caleb/rust-clippy/clippy_lints/src/undocumented_unsafe_blocks.rs:173:48
 5: <clippy_lints::undocumented_unsafe_blocks::UndocumentedUnsafeBlocks as rustc_lint::passes::LateLintPass>::check_block
           at /home/caleb/rust-clippy/clippy_lints/src/undocumented_unsafe_blocks.rs:70:16
 6: <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_block
 7: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_block
 8: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_expr
 9: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_block
10: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_expr
11: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_body
12: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_fn
13: rustc_hir::intravisit::walk_impl_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
14: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_impl_item
15: rustc_hir::intravisit::walk_impl_item_ref::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
16: rustc_hir::intravisit::walk_item::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
17: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
18: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
19: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_mod
20: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
21: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
22: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_mod
23: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_nested_item
24: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
25: <rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects> as rustc_hir::intravisit::Visitor>::visit_mod
26: <rustc_middle::hir::map::Map>::walk_toplevel_module::<rustc_lint::late::LateContextAndPass<rustc_lint::late::LateLintPassObjects>>
27: rustc_lint::late::late_lint_pass_crate::<rustc_lint::late::LateLintPassObjects>
28: <rustc_session::session::Session>::time::<(), rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#5}::{closure#0}::{closure#3}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
29: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}::{closure#0}::{closure#3}::{closure#0}>
30: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
31: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}>
32: rustc_interface::passes::analysis
33: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>
34: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
36: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
37: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
38: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
39: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}>
40: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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 (84a4ab7f3 2021-11-04)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `core_simd` due to 232 previous errors

@calebzulawski calebzulawski added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Nov 5, 2021
@dylni
Copy link

dylni commented Nov 6, 2021

MCVE for the same issue (add comment to #7868):

main.rs

#![warn(clippy::undocumented_unsafe_blocks)]

mod zero;

fn main() {}

zero.rs:

fn zero() {
    // SAFETY:
    unsafe { 0 };
}

@Serial-ATA
Copy link
Contributor

@rustbot claim

@kpreid
Copy link
Contributor

kpreid commented Jan 14, 2022

I went to try out clippy::undocumented_unsafe_blocks which is newly stable in 1.58.0, and hit this ICE, whose fix didn't make it into 1.58.0 stable (going by the branch info GitHub shows).

I'm mentioning this in case anyone else met the problem and is looking for information, and in a small hope of prompting a backport so it can be used (though from this it sounds like only fixes for regressions are backported?)

@daprilik
Copy link

Yep, just hit this one as well after updating to 1.58.0 stable 😞

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.

5 participants