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

internal compiler error: unexpected panic for issue #35896 #46101

Closed
gasabr opened this issue Nov 19, 2017 · 10 comments
Closed

internal compiler error: unexpected panic for issue #35896 #46101

gasabr opened this issue Nov 19, 2017 · 10 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@gasabr
Copy link

gasabr commented Nov 19, 2017

I'm learning rust and diesel, while trying to get the diesel::association::BelongTo working on my table, I tried this code:

#[derive(Queryable, Identifiable, BelongsTo::User, Clone)]
pub struct Game {
    pub id: i32,
    pub name: String,
    pub admin: i32,
    pub pwd: Option<String>,
    pub messages_enabled: bool,
    pub private: bool,
    pub n_players: i32,
    pub status: String,
}

I expected to see this happen: Nothing, to be honest, I thought BelongsTo::<User> should work, and BelongsTo::User does not make any sense to me.

Instead, this happened: I got the error message telling me to report this bug.

Meta

rustc --version --verbose:

rustc 1.21.0 (3b72af97e 2017-10-09)
binary: rustc
commit-hash: 3b72af97e42989b2fe104d8edbaee123cdf7c58f
commit-date: 2017-10-09
host: x86_64-apple-darwin
release: 1.21.0
LLVM version: 4.0

Backtrace:

   Compiling gotgame v0.1.0 (file:///Users/gasabr/Coding/gotgame)
error: non-ident macro paths are experimental (see issue #35896)
  --> src/models.rs:47:35
   |
47 | #[derive(Queryable, Identifiable, BelongsTo::User, Clone)]
   |                                   ^^^^^^^^^^^^^^^

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.21.0 (3b72af97e 2017-10-09) running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Expected Def::Macro(..)', src/librustc_resolve/build_reduced_graph.rs:555:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::get_macro
   6: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_invoc
   7: syntax::ext::expand::MacroExpander::expand
   8: syntax::ext::expand::MacroExpander::expand_crate
   9: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
  10: rustc_driver::driver::phase_2_configure_and_expand
  11: rustc_driver::driver::compile_input
  12: rustc_driver::run_compiler
@kennytm kennytm added A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Nov 19, 2017
@kennytm
Copy link
Member

kennytm commented Nov 19, 2017

Repro with 1.23-nightly on playground. Smaller test case:

#![feature(use_extern_macros)]
trait Foo {}
#[derive(Foo::Anything)]
struct S;

The input still ICE without #![feature(use_extern_macros)], but with a different stack trace.

error: non-ident macro paths are experimental (see issue #35896)
 --> 1.rs:3:10
  |
3 | #[derive(Foo::Anything)]
  |          ^^^^^^^^^^^^^
  |
  = help: add #![feature(use_extern_macros)] to the crate attributes to enable

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.23.0-nightly (aabfed5e0 2017-11-17) running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'no entry found for key', src/libcore/option.rs:874:4
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::option::expect_failed
  10: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::macro_def_scope
  11: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_invoc
  12: _ZN6syntax3ext6expand13MacroExpander6expand17h0e8dd401d8088c1eE.llvm.BAEFEFD9
  13: syntax::ext::expand::MacroExpander::expand_crate
  14: _ZN12rustc_driver6driver28phase_2_configure_and_expand28_$u7b$$u7b$closure$u7d$$u7d$17h519a719775ba2532E.llvm.E320C00D
  15: rustc::util::common::time
  16: rustc_driver::driver::compile_input
  17: rustc_driver::run_compiler

@kennytm kennytm added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) and removed A-attributes Area: Attributes (`#[…]`, `#![…]`) labels Nov 19, 2017
@arielb1
Copy link
Contributor

arielb1 commented Nov 19, 2017

cc @jseyfried

ICE backtrace without the #![feature]:

$ RUST_BACKTRACE=1 ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ice.rs 2>&1 | sed 's@/home/ariel/Rust/rust-master@rust:/@g'error: non-ident macro paths are experimental (see issue #35896)
 --> ice.rs:3:10
  |
3 | #[derive(Foo::Anything)]                                                                                                                                                                         
  |          ^^^^^^^^^^^^^                                                                                                                                                                           
  |                                                                                                                                                                                                  
  = help: add #![feature(use_extern_macros)] to the crate attributes to enable                                                                                                                       
                                                                                                                                                                                                     
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/blob/master/CONTRIBUTING.md#bug-reports                                                                                    
                                                                                                                                                                                                     
note: rustc 1.23.0-dev running on x86_64-unknown-linux-gnu                                                                                                                                           
                                                                                                                                                                                                     
note: run with `RUST_BACKTRACE=1` for a backtrace                                                                                                                                                    
                                                                                                                                                                                                     
thread 'rustc' panicked at 'no entry found for key', rust://src/libcore/option.rs:874:4                                                                                                              
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.                                                                                                              
stack backtrace:                                                                                                                                                                                     
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace                                                                                                                                       
             at rust://src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49                                                                                                                             
   1: std::sys_common::backtrace::_print                                                                                                                                                             
             at rust://src/libstd/sys_common/backtrace.rs:68                                                                                                                                         
   2: std::panicking::default_hook::{{closure}}                                                                                                                                                      
             at rust://src/libstd/sys_common/backtrace.rs:57                                                                                                                                         
             at rust://src/libstd/panicking.rs:381                                                                                                                                                   
   3: std::panicking::default_hook                                                                                                                                                                   
             at rust://src/libstd/panicking.rs:391                                                                                                                                                   
   4: std::panicking::rust_panic_with_hook                                                                                                                                                           
             at rust://src/libstd/panicking.rs:577                                                                                                                                                   
   5: std::panicking::begin_panic                                                                                                                                                                    
             at rust://src/libstd/panicking.rs:538                                                                                                                                                   
   6: std::panicking::begin_panic_fmt                                                                                                                                                                
             at rust://src/libstd/panicking.rs:522                                                                                                                                                   
   7: rust_begin_unwind                                                                                                                                                                              
             at rust://src/libstd/panicking.rs:498                                                                                                                                                   
   8: core::panicking::panic_fmt                                                                                                                                                                     
             at rust://src/libcore/panicking.rs:71                                                                                                                                                   
   9: core::option::expect_failed                                                                                                                                                                    
             at rust://src/libcore/option.rs:874                                                                                                                                                     
  10: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::macro_def_scope                                                                                                        
             at rust://src/librustc_resolve/build_reduced_graph.rs:0                                                                                                                                 
  11: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_invoc                                                                                       
             at rust://src/librustc_resolve/macros.rs:295                                                                                                                                            
  12: syntax::ext::expand::MacroExpander::expand                                                                                                                                                     
             at rust://src/libsyntax/ext/expand.rs:285                                                                                                                                               
  13: syntax::ext::expand::MacroExpander::expand_crate                                                                                                                                               
             at rust://src/libsyntax/ext/expand.rs:240                                                                                                                                               
  14: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
             at rust://src/librustc_driver/driver.rs:783
  15: rustc_driver::driver::phase_2_configure_and_expand
             at rust://src/librustc/util/common.rs:120
             at rust://src/librustc_driver/driver.rs:742
  16: rustc_driver::driver::compile_input
             at rust://src/librustc_driver/driver.rs:145
  17: rustc_driver::run_compiler
             at rust://src/librustc_driver/lib.rs:253

With the #![feature]:

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.23.0-dev running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Expected Def::Macro(..)', rust://src/librustc_resolve/build_reduced_graph.rs:571:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at rust://src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at rust://src/libstd/sys_common/backtrace.rs:68
   2: std::panicking::default_hook::{{closure}}
             at rust://src/libstd/sys_common/backtrace.rs:57
             at rust://src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at rust://src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at rust://src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at rust://src/libstd/panicking.rs:538
   6: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::get_macro
             at rust://src/librustc_resolve/build_reduced_graph.rs:571
   7: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_macro
             at rust://src/librustc_resolve/macros.rs:310
             at rust://src/libcore/result.rs:468
             at rust://src/librustc_resolve/macros.rs:308
   8: syntax::ext::expand::MacroExpander::expand
             at rust://src/libsyntax/ext/expand.rs:340
   9: syntax::ext::expand::MacroExpander::expand_crate
             at rust://src/libsyntax/ext/expand.rs:240
  10: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
             at rust://src/librustc_driver/driver.rs:783
  11: rustc_driver::driver::phase_2_configure_and_expand
             at rust://src/librustc/util/common.rs:120
             at rust://src/librustc_driver/driver.rs:742
  12: rustc_driver::driver::compile_input
             at rust://src/librustc_driver/driver.rs:145
  13: rustc_driver::run_compiler
             at rust://src/librustc_driver/lib.rs:253

@arielb1
Copy link
Contributor

arielb1 commented Nov 19, 2017

Looks like we have some debuginfo corruption:

  10: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::macro_def_scope                                                                                                        
             at rust://src/librustc_resolve/build_reduced_graph.rs:0                                                                                                                                 

@arielb1
Copy link
Contributor

arielb1 commented Nov 19, 2017

cc @michaelwoerister - could you try to figure out why we have debuginfo corruption in librustc_resolve?

@michaelwoerister
Copy link
Member

@arielb1 Looks like #44465 (which might be related to libbacktrace not fully supporting debuginfo for inlined functions). As far as I know nobody is looking into this issue at the moment.

@arielb1
Copy link
Contributor

arielb1 commented Nov 20, 2017

@michaelwoerister

The bugzilla looks like rustc is injecting line number 0 for some reason. I'll investigate.

@arielb1
Copy link
Contributor

arielb1 commented Nov 20, 2017

It looks like the "bad" line number comes from an unreachable following the call to expect_failed. I thought our unwinder was smart enough to use the line number of 1 byte before the return address (which should be within the call instruction) rather than the line number of the return address, but apparently libbacktrace doesn't do that.

        .loc    12 302 0
        leaq    str.k.llvm.133BC46B(%rip), %rdi
.Ltmp34:
        movl    $22, %esi
        callq   _ZN4core6option13expect_failed17hfad3c6cc869d0a50E@PLT
.Ltmp35:
        .loc    12 0 0 is_stmt 0
        ud2

@arielb1
Copy link
Contributor

arielb1 commented Nov 20, 2017

Nope, that's not the problem. The LLVM IR above works with libbacktrace (this was generated using LTO, which massages the IR in a way it does not encounter the problem).

@estebank
Copy link
Contributor

@estebank estebank added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Oct 24, 2018
varkor added a commit to varkor/rust that referenced this issue Feb 26, 2019
varkor added a commit to varkor/rust that referenced this issue Feb 27, 2019
varkor added a commit to varkor/rust that referenced this issue Mar 11, 2019
varkor added a commit to varkor/rust that referenced this issue Mar 12, 2019
@JohnTitor
Copy link
Member

The test for this was added in #58743, so we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

6 participants