Skip to content

Nightly crashing when building structopt using -Z sanitizer=address #83670

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

Closed
stusmall opened this issue Mar 30, 2021 · 3 comments
Closed

Nightly crashing when building structopt using -Z sanitizer=address #83670

stusmall opened this issue Mar 30, 2021 · 3 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@stusmall
Copy link

stusmall commented Mar 30, 2021

Code

I've pulled this code out of a larger project. Unfortunately I haven't been able to minimize it more yet but will try tomorrow.

https://github.com/stusmall/panic_rustc

EDIT 3/30: I reduced it down to just being an issue with importing structopt 0.3 and building with asan. Will try to reduce further

Meta

This only triggers when build with -Z sanitizer=address. Otherwise it builds fine

rustc --version --verbose:

rustc --version --verbose
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

   Compiling serde_derive v1.0.124
   Compiling thiserror-impl v1.0.24
   Compiling zstd-sys v1.4.20+zstd.1.4.9
   Compiling psm v0.1.12
   Compiling wasmtime-runtime v0.25.0
   Compiling tracing-attributes v0.1.15
   Compiling async-trait v0.1.48
   Compiling scroll_derive v0.10.5
   Compiling wasmtime-fiber v0.25.0
   Compiling wasmtime-rust-macro v0.25.0
   Compiling proc-macro-error v1.0.4
   Compiling cap-rand v0.13.7
   Compiling fs-set-times v0.3.1
   Compiling num v0.3.1
thread 'rustc' panicked at 'Failed to get crate data for crate21', compiler/rustc_metadata/src/creader.rs:136:32
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panicking.rs:435:5
   2: rustc_metadata::creader::CrateLoader::maybe_resolve_crate
   3: rustc_metadata::creader::CrateLoader::maybe_process_path_extern
   4: rustc_resolve::Resolver::extern_prelude_get
   5: rustc_resolve::macros::<impl rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope
   6: rustc_resolve::Resolver::resolve_path_with_ribs::{{closure}}
   7: rustc_resolve::Resolver::resolve_path_with_ribs
   8: rustc_resolve::imports::ImportResolver::resolve_imports
   9: rustc_resolve::macros::<impl rustc_expand::base::ResolverExpand for rustc_resolve::Resolver>::resolve_imports
  10: rustc_expand::expand::MacroExpander::fully_expand_fragment
  11: rustc_expand::expand::MacroExpander::expand_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::configure_and_expand_inner
  14: rustc_interface::passes::configure_and_expand::{{closure}}
  15: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  16: rustc_interface::passes::configure_and_expand
  17: rustc_interface::queries::Queries::expansion
  18: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  19: rustc_span::with_source_map
  20: rustc_interface::interface::create_compiler_and_run
  21: scoped_tls::ScopedKey<T>::set
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z sanitizer=address -C embed-bitcode=no -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `proc-macro-error`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

@stusmall stusmall added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 30, 2021
@stusmall
Copy link
Author

I worked on reducing this. All I need is to import structopt = "0.3" and build with RUSTFLAGS="-Z sanitizer=address" cargo build

I'll try and reduce further to find the trouble causer inside structopt

@stusmall stusmall changed the title Nightly crashing when using -Z sanitizer=address Nightly crashing when building structopt using -Z sanitizer=address Mar 30, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 30, 2021

This looks similar to #82991.

@tmiasko
Copy link
Contributor

tmiasko commented Feb 8, 2022

The ICE "Failed to get crate data" is already fixed.

Additionally it seems like you might be running into an issue where procedural macros are being instrumented. This can be avoided by passing --target ... flag to cargo, e.g., env RUSTFLAGS=-Zsanitizer=address cargo build --target x86_64-unknown-linux-gnu.

@tmiasko tmiasko closed this as completed Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants