Skip to content
New issue

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

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

Already on GitHub? # to your account

Infinite recursion/stack overflow in rustc_ast::mut_visit::noop_visit_expr #97222

Closed
clubby789 opened this issue May 20, 2022 · 6 comments
Closed
Labels
C-bug Category: This is a bug.

Comments

@clubby789
Copy link
Contributor

clubby789 commented May 20, 2022

I made a PR (here) marking many functions as const, and after running cargo build --lib --release in src/rust/iced-x86-js, rustc crashed with a segmentation fault.

Meta

The issue occurred when using nightly and 1.61, but not with 1.54 and 1.60

> rustc +1.61 --version --verbose
rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0
> rustc --version --verbose
rustc 1.63.0-nightly (c52b9c10b 2022-05-16)
binary: rustc
commit-hash: c52b9c10bfb5164015eb977ff498e0597ae63eb1
commit-date: 2022-05-16
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.4
Segfault Backtrace

<many more>
#8116 0x00007ffff612ea69 in rustc_ast::mut_visit::noop_visit_expr::<rustc_expand::expand::InvocationCollector> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8117 0x00007ffff6142f69 in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::visit_expr () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8118 0x00007ffff612ea69 in rustc_ast::mut_visit::noop_visit_expr::<rustc_expand::expand::InvocationCollector> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8119 0x00007ffff6142f69 in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::visit_expr () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8120 0x00007ffff612ea69 in rustc_ast::mut_visit::noop_visit_expr::<rustc_expand::expand::InvocationCollector> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8121 0x00007ffff6142f69 in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::visit_expr () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8122 0x00007ffff612ea69 in rustc_ast::mut_visit::noop_visit_expr::<rustc_expand::expand::InvocationCollector> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8123 0x00007ffff6142f69 in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::visit_expr () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8124 0x00007ffff612ea69 in rustc_ast::mut_visit::noop_visit_expr::<rustc_expand::expand::InvocationCollector> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8125 0x00007ffff614394f in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::filter_map_expr () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8126 0x00007ffff6140b2b in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::flat_map_stmt () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8127 0x00007ffff61351f0 in rustc_ast::mut_visit::noop_flat_map_assoc_item::<rustc_expand::expand::InvocationCollector> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8128 0x00007ffff613e2de in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::flat_map_impl_item () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8129 0x00007ffff617116e in <alloc::vec::Vec<rustc_ast::ptr::P<rustc_ast::ast::Item<rustc_ast::ast::AssocItemKind>>> as rustc_data_structures::map_in_place::MapInPlace<rustc_ast::ptr::P<rustc_ast::ast::Item<rustc_ast::ast::AssocItemKind>>>>::flat_map_in_place::<rustc_ast::mut_visit::noop_visit_item_kind<rustc_expand::expand::InvocationCollector>::{closure#7}, smallvec::SmallVec<[rustc_ast::ptr::P<rustc_ast::ast::Item<rustc_ast::ast::AssocItemKind>>; 1]>> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8130 0x00007ffff615f088 in <rustc_ast::ptr::P<rustc_ast::ast::Item> as rustc_expand::expand::InvocationCollectorNode>::wrap_flat_map_node_noop_flat_map::<<rustc_expand::expand::InvocationCollector>::flat_map_node<rustc_ast::ptr::P<rustc_ast::ast::Item>>::{closure#0}> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8131 0x00007ffff613d422 in <rustc_expand::expand::InvocationCollector as rustc_ast::mut_visit::MutVisitor>::flat_map_item () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8132 0x00007ffff6c295e3 in <smallvec::SmallVec<[rustc_ast::ptr::P<rustc_ast::ast::Item>; 1]> as rustc_data_structures::map_in_place::MapInPlace<rustc_ast::ptr::P<rustc_ast::ast::Item>>>::flat_map_in_place::<<rustc_expand::expand::AstFragment>::mut_visit_with<rustc_expand::expand::InvocationCollector>::{closure#2}, smallvec::SmallVec<[rustc_ast::ptr::P<rustc_ast::ast::Item>; 1]>> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8133 0x00007ffff6137d5d in <rustc_expand::expand::MacroExpander>::fully_expand_fragment () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8134 0x00007ffff6c35dee in <rustc_expand::expand::MacroExpander>::expand_crate () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8135 0x00007ffff659e1a4 in <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>, rustc_interface::passes::configure_and_expand::{closure#1}> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8136 0x00007ffff65976d3 in rustc_interface::passes::configure_and_expand () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8137 0x00007ffff65be897 in <rustc_interface::queries::Queries>::expansion () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8138 0x00007ffff65677f9 in <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::ErrorGuaranteed>> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so
#8139 0x00007ffff658ff4f in rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}> () from /home/jamie/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-3a280b26b15e2fbc.so

@clubby789 clubby789 added the C-bug Category: This is a bug. label May 20, 2022
wtfsck added a commit to icedland/iced that referenced this issue May 20, 2022
Reported to not crash with 1.60 but crashes with 1.61, see
rust-lang/rust#97222
wtfsck added a commit to icedland/iced that referenced this issue May 20, 2022
* Use an older version of Rust to work around a crash in 1.61+

Reported to not crash with 1.60 but crashes with 1.61, see
rust-lang/rust#97222

* Install more rust/cargo tools
@saethlin
Copy link
Member

I've run into this same segfault via the crate k2_tree, where this seems to be coming from a huge bitvec::bitvec! macro expansion.

@ghost
Copy link

ghost commented Jul 10, 2022

I've run into this same segfault via the crate k2_tree, where this seems to be coming from a huge bitvec::bitvec! macro expansion.

Minimized reproducible from k2_tree -> https://gist.github.com/gimbles/d43c181534fc4bd022abe98ca328039c

@ghost
Copy link

ghost commented Jul 10, 2022

I think I will be able to bisect this, but cargo-bisect-rustc does not have a segmentation fault regression, so might take a while doing this by hand. =)

@ghost
Copy link

ghost commented Jul 10, 2022

Current status of doing some hand bisection -> (edited)

Bisected! Segfaults on nightly-2022-01-18.

@ghost
Copy link

ghost commented Jul 16, 2022

I have found the problem! 👏🏻

Similar to #98458, this only occurs in Rustup built toolchains. Build goes with expected behaviour on locally built toolchains.

@clubby789
Copy link
Contributor Author

The code appears to compile on latest nightly now, so closing this

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants