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 - 'cannot access a scoped thread local variable without calling set first' #63283

Closed
omerbenamram opened this issue Aug 5, 2019 · 6 comments
Labels
A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

@omerbenamram
Copy link

omerbenamram commented Aug 5, 2019

Hello,

After updating nightly version to 2019-07-31 (also fails on 2019-08-04), previously working code no longer compiles.
I can confirm that it compiles successfully on nightly-2019-07-30.

EDIT: Happens on debug aswell, also doesn't happen on macOS, but I'm not sure whether it's a transitive dependency or a windows specific thing.

Traceback:

thread 'rustc' panicked at 'cannot access a scoped thread local variable without calling `set` first', C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-1.0.0\src\lib.rs:168:9                             
stack backtrace:                                                                                                                                                                                                                               
   0: std::sys_common::alloc::realloc_fallback                                                                                                                                                                                                 
   1: std::panicking::take_hook                                                                                                                                                                                                                
   2: std::panicking::take_hook                                                                                                                                                                                                                
   3: <rustc::ty::layout::LayoutCx<rustc::ty::query::TyCtxtAt> as rustc_target::abi::LayoutOf>::layout_of                                                                                                                                      
   4: std::panicking::rust_panic_with_hook                                                                                                                                                                                                     
   5: std::panicking::begin_panic                                                                                                                                                                                                              
   6: scoped_tls::ScopedKey<T>::with                                                                                                                                                                                                           
   7: syntax_pos::symbol::InternedString::intern                                                                                                                                                                                               
   8: rustc_plugin::registry::Registry::register_macro                                                                                                                                                                                         
   9: _rustc_plugin_registrar_c4a9050c6e5e6ab11ae9f48c182f5a1b__                                                                                                                                                                               
  10: <humantime::date::Rfc3339Timestamp as core::fmt::Debug>::fmt                                                                                                                                                                             
  11: <humantime::date::Rfc3339Timestamp as core::fmt::Debug>::fmt                                                                                                                                                                             
  12: rustc_interface::passes::BoxedResolver::to_expansion_result                                                                                                                                                                              
  13: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::compile                                                                                                                                                           
  14: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::register_plugins                                                                                                                                                  
  15: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt                                                                                                                                                                      
  16: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt                                                                                                                                                                      
  17: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt                                                                                                                                                                      
  18: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt                                                                                                                                                                      
  19: _rust_maybe_catch_panic                                                                                                                                                                                                                  
  20: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt                                                                                                                                                                      
  21: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..
mt..Display$GT$3fmt17                                                                                                                                                                                                                          
  22: std::sys::windows::thread::Thread::new                                                                                                                                                                                                   
  23: BaseThreadInitThunk                                                                                                                                                                                                                      
  24: RtlUserThreadStart                                                                                                                                                                                                                       
query stack during panic:                                                                                                                                                                                                                      
end of query stack                                                                                                                                                                                                                             
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.38.0-nightly (8a58268b5 2019-07-31) running on x86_64-pc-windows-msvc

note: compiler flags: -C opt-level=3 --crate-type lib

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

The repo is private so unfortunately i cannot link to it.
If there are any details that may help debugging this I will be happy to assist :)

Thanks!

@hellow554
Copy link
Contributor

hellow554 commented Aug 5, 2019

You could try to minimize the example and try to create a mcve. If you need help with it, you can ask here. I can give you some guideance.

@rustbot modify labels: E-needs-mcve I-ICE C-bug T-compiler A-thread-locals

@rustbot rustbot added A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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 Aug 5, 2019
@omerbenamram
Copy link
Author

omerbenamram commented Aug 5, 2019

@hellow554 I've minimized it quite a bit. It seems to be an issue with a plugin that we have that encrypts strings. I don't have a problem sharing this code so:

https://github.com/omerbenamram/rust-63283-mcve

cargo +nightly-2019-07-31 run should ICE (on windows).

This plugin has been broken on nightly updates before, but never crashed.

@hellow554
Copy link
Contributor

Plugins are kind of deprecated in favor of proc macros. You should concider upgrading them in the future.

Unfortunately the ICE does not occur neither on my linux nor on my windows machine. Maybe it's an incremental compiling problem? Is the error still present if you do cargo clean first and build afterwards?

@petrochenkov
Copy link
Contributor

This may be a duplicate of #62717.
In that case it can be fixed by linking to rustc_driver.

cc #62727

@omerbenamram
Copy link
Author

@hellow554 it still happens after cargo clean here.
I'm running windows 10 build 1903 (18362.267).
Are there any other details that could affect rustc in that regard?

@omerbenamram
Copy link
Author

@petrochenkov linking against rustc_driver prevents the ICE. nice :)

akiradeveloper added a commit to akiradeveloper/cargo-snippet that referenced this issue Nov 5, 2019
To prevent the error we see when compiling cargo-snippet 0.3 with the nightly (1.40) rustc_driver should be linked with.
thread 'rustc' panicked at 'cannot access a scoped thread local variable without calling `set` first', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:168:9

ref: rust-lang/rust#63283

Signed-off-by: Akira Hayakawa <ruby.wktk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

4 participants