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

SIGABRT from malformed cfg in a closure #79829

Closed
AaronKutch opened this issue Dec 8, 2020 · 9 comments
Closed

SIGABRT from malformed cfg in a closure #79829

AaronKutch opened this issue Dec 8, 2020 · 9 comments
Labels
A-parser Area: The parsing of Rust source code to an AST. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@AaronKutch
Copy link
Contributor

fn bug() {
    let _ = || {
        #[cfg(not(target_arch == "x86"))] {}
    };
}

when compiled (this works on nightly and beta, so I presume it also happens on stable), this produces:

error: expected one of `(`, `)`, `,`, `::`, or `=`, found `==`
 --> src\lib.rs:3:31
  |
3 |         #[cfg(not(target_arch == "x86"))] {}
  |                               ^^ expected one of `(`, `)`, `,`, `::`, or `=`

error: could not compile `testlib`

Caused by:
  process didn't exit successfully: `rustc --crate-name testlib --edition=2018 src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=0ff8eeface1c2012 -C extra-filename=-0ff8eeface1c2012 --out-dir C:\Users\aaron\Documents\github\testlib\target\debug\deps -C incremental=C:\Users\aaron\Documents\github\testlib\target\debug\incremental -L dependency=C:\Users\aaron\Documents\github\testlib\target\debug\deps` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

Backtrace does not work.

@AaronKutch AaronKutch 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 Dec 8, 2020
@jonas-schievink jonas-schievink added A-parser Area: The parsing of Rust source code to an AST. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 8, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 8, 2020

This is not a stack overflow, it's an actual abort.

error: expected one of `(`, `)`, `,`, `::`, or `=`, found `==`
 --> cfg-overflow.rs:3:31
  |
3 |         #[cfg(not(target_arch == "x86"))] {}
  |                               ^^ expected one of `(`, `)`, `,`, `::`, or `=`


Thread 2 "rustc" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffed9ff700 (LWP 2132847)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) where
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff2fe6859 in __GI_abort () at abort.c:79
#2  0x00007ffff32c8e77 in std::sys::unix::abort_internal ()
    at library/std/src/sys/unix/mod.rs:237
#3  0x00007ffff32b2026 in std::process::abort () at library/std/src/process.rs:1784
#4  0x00007ffff5c37914 in rustc_ast::mut_visit::visit_clobber::{{closure}} ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#5  0x00007ffff5c3eab8 in rustc_ast::mut_visit::noop_visit_expr ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#6  0x00007ffff5bf8792 in <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#7  0x00007ffff5c41a92 in rustc_ast::mut_visit::noop_visit_local ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#8  0x00007ffff5c4a8a4 in rustc_ast::mut_visit::noop_flat_map_stmt_kind ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#9  0x00007ffff5bd2b36 in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::flat_map_stmt ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#10 0x00007ffff5b94d02 in <alloc::vec::Vec<T> as rustc_data_structures::map_in_place::MapInPlace<T>>::flat_map_in_place ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#11 0x00007ffff5c474bf in rustc_ast::mut_visit::noop_visit_item_kind ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#12 0x00007ffff5c43227 in rustc_ast::mut_visit::noop_flat_map_item ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#13 0x00007ffff5bd3c7b in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::flat_map_item ()
   from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin--Type <RET> for more, q to quit, c to continue without paging--c
/../lib/librustc_driver-74194b4af230f3a4.so
#14 0x00007ffff5b9fe4a in <alloc::vec::Vec<T> as rustc_data_structures::map_in_place::MapInPlace<T>>::flat_map_in_place () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#15 0x00007ffff5c474f4 in rustc_ast::mut_visit::noop_visit_item_kind () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#16 0x00007ffff5c43227 in rustc_ast::mut_visit::noop_flat_map_item () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#17 0x00007ffff5bd3c7b in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::flat_map_item () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#18 0x00007ffff5c556f1 in <smallvec::SmallVec<A> as rustc_data_structures::map_in_place::MapInPlace<T>>::flat_map_in_place () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#19 0x00007ffff5bcd6c4 in rustc_expand::expand::MacroExpander::collect_invocations () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#20 0x00007ffff5bc8e4f in rustc_expand::expand::MacroExpander::fully_expand_fragment () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#21 0x00007ffff5bc862e in rustc_expand::expand::MacroExpander::expand_crate () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#22 0x00007ffff3d8de58 in rustc_session::utils::<impl rustc_session::session::Session>::time () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#23 0x00007ffff3dcc088 in rustc_interface::passes::configure_and_expand_inner () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#24 0x00007ffff3d84657 in rustc_interface::passes::configure_and_expand::{{closure}} () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#25 0x00007ffff3d753df in rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#26 0x00007ffff3dcb2c8 in rustc_interface::passes::configure_and_expand () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#27 0x00007ffff3e26a9f in rustc_interface::queries::Queries::expansion () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#28 0x00007ffff3b17e61 in rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#29 0x00007ffff3bab5f7 in rustc_span::with_source_map () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#30 0x00007ffff3b1968b in rustc_interface::interface::create_compiler_and_run () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#31 0x00007ffff3bc5b60 in scoped_tls::ScopedKey<T>::set () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#32 0x00007ffff3bcc346 in std::sys_common::backtrace::__rust_begin_short_backtrace () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#33 0x00007ffff3b2107a in core::ops::function::FnOnce::call_once{{vtable-shim}} () from /home/joshua/.local/lib/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-74194b4af230f3a4.so
#34 0x00007ffff32c865a in <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once () at /rustc/0f6f2d681b39c5f95459cd09cb936b6ceb27cd82/library/alloc/src/boxed.rs:1328
#35 <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once () at /rustc/0f6f2d681b39c5f95459cd09cb936b6ceb27cd82/library/alloc/src/boxed.rs:1328
#36 std::sys::unix::thread::Thread::new::thread_start () at library/std/src/sys/unix/thread.rs:71
#37 0x00007ffff31cd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#38 0x00007ffff30e3293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

pub fn visit_clobber<T, F>(t: &mut T, f: F)
where
F: FnOnce(T) -> T,
{
unsafe {
// Safe because `t` is used in a read-only fashion by `read()` before
// being overwritten by `write()`.
let old_t = ptr::read(t);
let new_t = panic::catch_unwind(panic::AssertUnwindSafe(|| f(old_t)))
.unwrap_or_else(|_| process::abort());
ptr::write(t, new_t);
}
}

@jyn514 jyn514 changed the title Stack overflow from malformed cfg in a closure SIGABRT from malformed cfg in a closure Dec 8, 2020
@AaronKutch
Copy link
Contributor Author

Why would it have STATUS_STACK_BUFFER_OVERRUN in the message?

@jyn514
Copy link
Member

jyn514 commented Dec 8, 2020

https://devblogs.microsoft.com/oldnewthing/20190108-00/?p=100655

@camelid camelid added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Dec 9, 2020
@camelid
Copy link
Member

camelid commented Dec 9, 2020

Currently running a build to see how hard this will be to fix.

@camelid
Copy link
Member

camelid commented Dec 9, 2020

Okay, it seems that if I remove the catch_unwind wrapper it causes a double-free, so that won't fix it ;)

I guess the fix would be to fix the closure that's panicking?

@jyn514
Copy link
Member

jyn514 commented Dec 9, 2020

@camelid yes, you need to find what the ignored panic payload is and what's causing the panic.

@camelid camelid self-assigned this Dec 9, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 9, 2020

@AaronKutch FYI you can fix the invalid syntax by using = instead of ==, I didn't realize the code was invalid until now. Thanks for the bug report though :)

@apiraino
Copy link
Contributor

apiraino commented Dec 9, 2020

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 9, 2020
@camelid camelid removed their assignment Dec 12, 2020
@ehuss
Copy link
Contributor

ehuss commented Jan 6, 2024

Closing as effectively resolved by #91519.

@ehuss ehuss closed this as completed Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. P-medium Medium priority 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

6 participants