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

Compiler crashes when loading macros from a crate that contains syntax extensions #13474

Closed
vosen opened this issue Apr 12, 2014 · 6 comments
Closed
Labels
A-syntaxext Area: Syntax extensions I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-windows Operating system: Windows

Comments

@vosen
Copy link
Contributor

vosen commented Apr 12, 2014

Rustc crashes when running following code:

#![feature(phase)]

#[phase(syntax)] extern crate fourcc;

fn main() { }

Here's gdb output:

(gdb) r fourcc-crash.rs
Starting program: D:\dev\Rust\bin\rustc.exe fourcc-crash.rs
[New Thread 3524.0x1894]
[New Thread 3524.0x14f4]

You've met with a terrible fate, haven't you?

fatal runtime error: runtime tls key not initialized
stack backtrace:
   1: 0x6eeb1a3f
   2: 0x6ef13a28
   3: 0x6eeb370f
   4: 0x712c12c3
   5:  0x18b8332

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 3524.0x14f4]
0x6eeb1a59 in rt::util::abort::h439cebf64f55f5c1U4a::v0.11.pre () from D:\dev\Rust\bin\std-aad93cea-0.11-pre.dll
(gdb) bt
#0  0x6eeb1a59 in rt::util::abort::h439cebf64f55f5c1U4a::v0.11.pre () from D:\dev\Rust\bin\std-aad93cea-0.11-pre.dll
#1  0x6ef13a28 in rt::local_ptr::native::unsafe_borrow::h0d5317ed6ed9ce06fW9::v0.11.pre ()
   from D:\dev\Rust\bin\std-aad93cea-0.11-pre.dll
#2  0x6eeb370f in local_data::get_local_map::h6aadaf5daa81cd9c0pF::v0.11.pre () from D:\dev\Rust\bin\std-aad93cea-0.11-pre.dll
#3  0x678f52d7 in parse::token::get_ident_interner::h0bb6c51e2d627c67UjI::v0.11.pre ()
   from D:\dev\Rust\bin\syntax-5de2fc8e-0.11-pre.dll
#4  0x712c12c3 in macro_registrar::h5cf23ffc818750f9vaa::v0.11.pre ()
   from D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\fourcc-e7a24ce8-0.11-pre.dll
#5  0x018b8332 in ext::expand::load_extern_macros::h08746a7dabbaf50avGR::v0.11.pre ()
#6  0x018b11bb in fold::noop_fold_mod::closure.26381 ()
#7  0x018b0eab in iter::Iterator::collect::ha510073717ed79ffV03::v0.11.pre ()
#8  0x018b0d03 in fold::Folder::fold_mod::h3063a8a13c6911b8d5x::v0.11.pre ()
#9  0x018d449d in ext::expand::expand_crate::h5be3510f9f4aeaebn4R::v0.11.pre ()
#10 0x00b838b6 in driver::driver::phase_2_configure_and_expand::closure.88027 ()
#11 0x00b832e9 in util::common::time::h176addc10893f0b78Pg::v0.11.pre ()
#12 0x00b812f5 in driver::driver::phase_2_configure_and_expand::h5264ff43d70fb058kye::v0.11.pre ()
#13 0x00bbe512 in driver::driver::compile_input::hda7d83b4f81d42b9D1e::v0.11.pre ()
#14 0x00be34c4 in run_compiler::hcafaeca05b1b783eIxm::v0.11.pre ()
#15 0x00bf5267 in main_args::closure.92185 ()
#16 0x00bf3c69 in monitor::closure.92070 ()
#17 0x00befefe in task::TaskBuilder::try::closure.91842 ()
#18 0x004274b3 in task::spawn_opts::closure.7691 ()
#19 0x01a5acac in rt::task::Task::run::closure.40013 ()
#20 0x01a5ed05 in rt::unwind::Unwinder::try::try_fn::he27cd916ec604645k79::v0.11.pre ()
#21 0x01a66016 in rust_try ()
#22 0x01a5ab84 in rt::task::Task::run::hd417a7b2504dfe98eA8::v0.11.pre ()
#23 0x00427360 in task::spawn_opts::closure.7664 ()
#24 0x01a5e0ed in rt::thread::thread_start::h63560cc2549b235dWe9::v0.11.pre ()
#25 0x74cb495d in KERNEL32!BaseThreadInitThunk () from C:\Windows\SysWOW64\kernel32.dll
#26 0x772598ee in ?? ()
#27 0x772598c4 in ?? ()
#28 0x00000000 in ?? ()

Note, it works fine with crates that use macros defined with macro_rules (e.g. log) or with phase(link) instead of phase(syntax).

I'm using Windows 8.1 x64 with nightly installer that I've had downloaded few hours ago, but I've also installed 0.10 and it has the same problem:

@sfackler
Copy link
Member

It looks like it might be running two libsyntaxes in parallel.

@edwardw
Copy link
Contributor

edwardw commented Apr 12, 2014

Windows only bug? The same program works fine for me on OS X.

@alexcrichton
Copy link
Member

Can you paste the output of RUST_LOG=rustc::metadata::loader?

@vosen
Copy link
Contributor Author

vosen commented Apr 12, 2014

Sure:

rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-aad93cea-0.11-pre.rlib
matching -- libstd-aad93cea-0.11-pre.rlib, middle: aad93cea-0.11-pre
matching -- libstd-aad93cea-0.11-pre.rlib, hash: aad93cea (want aad93cea)
matching -- libstd-aad93cea-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- libstd-aad93cea-0.11-pre.rlib, vers ok
matching -- libstd-aad93cea-0.11-pre.rlib, hash ok
rlib accepted, hash: aad93cea
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\std-aad93cea-0.11-pre.dll
matching -- std-aad93cea-0.11-pre.dll, middle: aad93cea-0.11-pre
matching -- std-aad93cea-0.11-pre.dll, hash: aad93cea (want aad93cea)
matching -- std-aad93cea-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- std-aad93cea-0.11-pre.dll, vers ok
matching -- std-aad93cea-0.11-pre.dll, hash ok
dylib accepted, hash: aad93cea
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libstd-aad93cea-0.11-pre.rlib
reading libstd-aad93cea-0.11-pre.rlib => 0ms
rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\liblibc-3574b280-0.11-pre.rlib
matching -- liblibc-3574b280-0.11-pre.rlib, middle: 3574b280-0.11-pre
matching -- liblibc-3574b280-0.11-pre.rlib, hash: 3574b280 (want 3574b280)
matching -- liblibc-3574b280-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- liblibc-3574b280-0.11-pre.rlib, vers ok
matching -- liblibc-3574b280-0.11-pre.rlib, hash ok
rlib accepted, hash: 3574b280
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libc-3574b280-0.11-pre.dll
matching -- libc-3574b280-0.11-pre.dll, middle: 3574b280-0.11-pre
matching -- libc-3574b280-0.11-pre.dll, hash: 3574b280 (want 3574b280)
matching -- libc-3574b280-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- libc-3574b280-0.11-pre.dll, vers ok
matching -- libc-3574b280-0.11-pre.dll, hash ok
dylib accepted, hash: 3574b280
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\liblibc-3574b280-0.11-pre.rlib
reading liblibc-3574b280-0.11-pre.rlib => 0ms
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\fourcc-e7a24ce8-0.11-pre.dll
matching -- fourcc-e7a24ce8-0.11-pre.dll, middle: e7a24ce8-0.11-pre
matching -- fourcc-e7a24ce8-0.11-pre.dll, hash: e7a24ce8 (want c66368c9)
matching -- fourcc-e7a24ce8-0.11-pre.dll, vers: 0.11-pre (want None)
dylib accepted, hash: e7a24ce8
dylib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\fourcc-e7a24ce8-0.11-pre.dll
get_metadata_section: name .text
get_metadata_section: name .data
get_metadata_section: name .note.rustc
checking 8 bytes of metadata-version stamp
inflating 3576 bytes of compressed metadata
reading fourcc-e7a24ce8-0.11-pre.dll => 0ms
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\syntax-5de2fc8e-0.11-pre.dll
matching -- syntax-5de2fc8e-0.11-pre.dll, middle: 5de2fc8e-0.11-pre
matching -- syntax-5de2fc8e-0.11-pre.dll, hash: 5de2fc8e (want 5de2fc8e)
matching -- syntax-5de2fc8e-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- syntax-5de2fc8e-0.11-pre.dll, vers ok
matching -- syntax-5de2fc8e-0.11-pre.dll, hash ok
dylib accepted, hash: 5de2fc8e
dylib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\syntax-5de2fc8e-0.11-pre.dll
get_metadata_section: name .text
get_metadata_section: name .data
get_metadata_section: name .note.rustc
checking 8 bytes of metadata-version stamp
inflating 2762232 bytes of compressed metadata
reading syntax-5de2fc8e-0.11-pre.dll => 48ms
rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\liblog-933ace35-0.11-pre.rlib
matching -- liblog-933ace35-0.11-pre.rlib, middle: 933ace35-0.11-pre
matching -- liblog-933ace35-0.11-pre.rlib, hash: 933ace35 (want 933ace35)
matching -- liblog-933ace35-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- liblog-933ace35-0.11-pre.rlib, vers ok
matching -- liblog-933ace35-0.11-pre.rlib, hash ok
rlib accepted, hash: 933ace35
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\log-933ace35-0.11-pre.dll
matching -- log-933ace35-0.11-pre.dll, middle: 933ace35-0.11-pre
matching -- log-933ace35-0.11-pre.dll, hash: 933ace35 (want 933ace35)
matching -- log-933ace35-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- log-933ace35-0.11-pre.dll, vers ok
matching -- log-933ace35-0.11-pre.dll, hash ok
dylib accepted, hash: 933ace35
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\liblog-933ace35-0.11-pre.rlib
reading liblog-933ace35-0.11-pre.rlib => 0ms
rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libsync-e32f1ba2-0.11-pre.rlib
matching -- libsync-e32f1ba2-0.11-pre.rlib, middle: e32f1ba2-0.11-pre
matching -- libsync-e32f1ba2-0.11-pre.rlib, hash: e32f1ba2 (want e32f1ba2)
matching -- libsync-e32f1ba2-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- libsync-e32f1ba2-0.11-pre.rlib, vers ok
matching -- libsync-e32f1ba2-0.11-pre.rlib, hash ok
rlib accepted, hash: e32f1ba2
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\sync-e32f1ba2-0.11-pre.dll
matching -- sync-e32f1ba2-0.11-pre.dll, middle: e32f1ba2-0.11-pre
matching -- sync-e32f1ba2-0.11-pre.dll, hash: e32f1ba2 (want e32f1ba2)
matching -- sync-e32f1ba2-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- sync-e32f1ba2-0.11-pre.dll, vers ok
matching -- sync-e32f1ba2-0.11-pre.dll, hash ok
dylib accepted, hash: e32f1ba2
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libsync-e32f1ba2-0.11-pre.rlib
reading libsync-e32f1ba2-0.11-pre.rlib => 0ms
rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libserialize-0f7a3487-0.11-pre.rlib
matching -- libserialize-0f7a3487-0.11-pre.rlib, middle: 0f7a3487-0.11-pre
matching -- libserialize-0f7a3487-0.11-pre.rlib, hash: 0f7a3487 (want 0f7a3487)
matching -- libserialize-0f7a3487-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- libserialize-0f7a3487-0.11-pre.rlib, vers ok
matching -- libserialize-0f7a3487-0.11-pre.rlib, hash ok
rlib accepted, hash: 0f7a3487
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\serialize-0f7a3487-0.11-pre.dll
matching -- serialize-0f7a3487-0.11-pre.dll, middle: 0f7a3487-0.11-pre
matching -- serialize-0f7a3487-0.11-pre.dll, hash: 0f7a3487 (want 0f7a3487)
matching -- serialize-0f7a3487-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- serialize-0f7a3487-0.11-pre.dll, vers ok
matching -- serialize-0f7a3487-0.11-pre.dll, hash ok
dylib accepted, hash: 0f7a3487
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libserialize-0f7a3487-0.11-pre.rlib
reading libserialize-0f7a3487-0.11-pre.rlib => 0ms
rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libcollections-bfc127c2-0.11-pre.rlib
matching -- libcollections-bfc127c2-0.11-pre.rlib, middle: bfc127c2-0.11-pre
matching -- libcollections-bfc127c2-0.11-pre.rlib, hash: bfc127c2 (want bfc127c2)
matching -- libcollections-bfc127c2-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- libcollections-bfc127c2-0.11-pre.rlib, vers ok
matching -- libcollections-bfc127c2-0.11-pre.rlib, hash ok
rlib accepted, hash: bfc127c2
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\collections-bfc127c2-0.11-pre.dll
matching -- collections-bfc127c2-0.11-pre.dll, middle: bfc127c2-0.11-pre
matching -- collections-bfc127c2-0.11-pre.dll, hash: bfc127c2 (want bfc127c2)
matching -- collections-bfc127c2-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- collections-bfc127c2-0.11-pre.dll, vers ok
matching -- collections-bfc127c2-0.11-pre.dll, hash ok
dylib accepted, hash: bfc127c2
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libcollections-bfc127c2-0.11-pre.rlib
reading libcollections-bfc127c2-0.11-pre.rlib => 0ms
rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\librand-dd29dab1-0.11-pre.rlib
matching -- librand-dd29dab1-0.11-pre.rlib, middle: dd29dab1-0.11-pre
matching -- librand-dd29dab1-0.11-pre.rlib, hash: dd29dab1 (want dd29dab1)
matching -- librand-dd29dab1-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- librand-dd29dab1-0.11-pre.rlib, vers ok
matching -- librand-dd29dab1-0.11-pre.rlib, hash ok
rlib accepted, hash: dd29dab1
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\rand-dd29dab1-0.11-pre.dll
matching -- rand-dd29dab1-0.11-pre.dll, middle: dd29dab1-0.11-pre
matching -- rand-dd29dab1-0.11-pre.dll, hash: dd29dab1 (want dd29dab1)
matching -- rand-dd29dab1-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- rand-dd29dab1-0.11-pre.dll, vers ok
matching -- rand-dd29dab1-0.11-pre.dll, hash ok
dylib accepted, hash: dd29dab1
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\librand-dd29dab1-0.11-pre.rlib
reading librand-dd29dab1-0.11-pre.rlib => 0ms
rlib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libterm-2fd119ea-0.11-pre.rlib
matching -- libterm-2fd119ea-0.11-pre.rlib, middle: 2fd119ea-0.11-pre
matching -- libterm-2fd119ea-0.11-pre.rlib, hash: 2fd119ea (want 2fd119ea)
matching -- libterm-2fd119ea-0.11-pre.rlib, vers: 0.11-pre (want Some(0.11-pre))
matching -- libterm-2fd119ea-0.11-pre.rlib, vers ok
matching -- libterm-2fd119ea-0.11-pre.rlib, hash ok
rlib accepted, hash: 2fd119ea
dylib candidate: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\term-2fd119ea-0.11-pre.dll
matching -- term-2fd119ea-0.11-pre.dll, middle: 2fd119ea-0.11-pre
matching -- term-2fd119ea-0.11-pre.dll, hash: 2fd119ea (want 2fd119ea)
matching -- term-2fd119ea-0.11-pre.dll, vers: 0.11-pre (want Some(0.11-pre))
matching -- term-2fd119ea-0.11-pre.dll, vers ok
matching -- term-2fd119ea-0.11-pre.dll, hash ok
dylib accepted, hash: 2fd119ea
rlib reading metadata from: D:\dev\Rust\bin\rustlib\i686-pc-mingw32\lib\libterm-2fd119ea-0.11-pre.rlib
reading libterm-2fd119ea-0.11-pre.rlib => 0ms

You've met with a terrible fate, haven't you?

fatal runtime error: runtime tls key not initialized
stack backtrace:
   1: 0x6eeb1a3f
   2: 0x6ef13a28
   3: 0x6eeb370f
   4: 0x712c12c3
   5:  0x18b8332

@alexcrichton
Copy link
Member

Hm, it appears that this is indeed a windows-only bug. From what I can tell this is happening because loading a dynamic library on windows will also always load its dependencies. This means that there's two copies of the standard library running around, which is always a recipe for disaster (as seen, the TLS key isn't initialized).

I believe that it's re-loading libstd because of #13491 (libstd should be a dynamically linked library for rustc).

alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 14, 2014
In the past, windows was installed from stage3 to guarantee convergence between
the host and target artifacts, but syntax extensions on all platforms are
currently relying on convergence, so special casing this one platform has become
less relevant over time.

This will also have the added benefit of dealing with rust-lang#13474 and rust-lang#13491. These
issues will be closed after next next nightly is confirmed to fix them.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 16, 2014
In the past, windows was installed from stage3 to guarantee convergence between
the host and target artifacts, but syntax extensions on all platforms are
currently relying on convergence, so special casing this one platform has become
less relevant over time.

This will also have the added benefit of dealing with rust-lang#13474 and rust-lang#13491. These
issues will be closed after next next nightly is confirmed to fix them.
@alexcrichton
Copy link
Member

Closed by efec34a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

4 participants