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

"thread 'rustc' has overflowed its stack" in glium on Linux #26467

Closed
tomaka opened this issue Jun 21, 2015 · 15 comments
Closed

"thread 'rustc' has overflowed its stack" in glium on Linux #26467

tomaka opened this issue Jun 21, 2015 · 15 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tomaka
Copy link
Contributor

tomaka commented Jun 21, 2015

Glium's master branch currently compiles just fine, but this simple pull request makes the compilation fail with:

thread 'rustc' has overflowed its stack

This only happens on Linux and not Windows. Stable and nightly are both affected.

The gl_generator dependency is only used a build dependency to generate some Rust code that is then include!ed in glium. There are only three differences between the Rust code generated by gl_generator 0.0.27 (which overflows) and the code generated by gl_generator 0.0.25 (which works). Two #[derive(Clone)] lines added and one #[allow(raw_pointer_derive)].

One of the two structs newly affected by #[derive(Clone)] is huge (around 2000 members). However the struct compiles just fine by itself. It is used as a field in glium's Context struct but Context itself doesn't derive Clone.

Because of this diagnostic I fear that this is a "real" stack overflow and not just a bug leading to an infinite recursion.

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 21, 2015
@arielb1
Copy link
Contributor

arielb1 commented Jun 21, 2015

Could someone post a stack trace with debuginfo?

@alexcrichton
Copy link
Member

Can you also try compiling with RUST_MIN_STACK set to a large value? This may be a legitimate stack overflow.

@tomaka
Copy link
Contributor Author

tomaka commented Jun 21, 2015

Can you also try compiling with RUST_MIN_STACK set to a large value? This may be a legitimate stack overflow.

It worked with 20000000

@arielb1
Copy link
Contributor

arielb1 commented Jun 21, 2015

I don't think we should use a stack so large! Could you gist a stack-trace so we can fix this worst-case?

@tomaka
Copy link
Contributor Author

tomaka commented Jun 21, 2015

For some reason RUST_BACKTRACE=1 cargo build doesn't work (no backtrace is shown).

I tried to manually run rustc with RUST_BACKTRACE=1 by copy-pasting the command printed by cargo build --verbose, but that didn't print a backtrace either.
And because of multirust I didn't manage to run it in gdb.

@alexcrichton
Copy link
Member

@tomaka you may be able to get the most mileage out of:

multirust run stable gdb --args rustc ...

@tomaka
Copy link
Contributor Author

tomaka commented Jun 22, 2015

That worked!

#0  0x00007ffff75a7d6e in rust_stack_exhausted ()
   from /home/pierre/.multirust/toolchains/stable/lib/libstd-4e7c5e5c.so
#1  0x00007ffff57f2081 in __morestack ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc-4e7c5e5c.so
#2  0x00007ffff55b7a5a in middle::subst::SubstFolder$LT$$u27$a$C$$u20$$u27$tcx$GT$.TypeFolder$LT$$u27$tcx$GT$::fold_ty::h8e9ff889f5da0ecfizN ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc-4e7c5e5c.so
#3  0x00007ffff6dae7d4 in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#4  0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#5  0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#6  0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#7  0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#8  0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#9  0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#10 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#11 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#12 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#13 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#14 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#15 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#16 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#17 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#18 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#19 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#20 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#21 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#22 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#23 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#24 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#25 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#26 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#27 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#28 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#29 0x00007ffff6db2b1b in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so

... and so on ...

#2766 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2767 0x00007ffff6db027c in trans::_match::compile_submatch_continue::h394de38ef5e3510afAH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2768 0x00007ffff6dadbb6 in trans::_match::compile_submatch::hbf2d0204fcc69edaluH ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2769 0x00007ffff6db56aa in trans::_match::trans_match_inner::h6119af2a2800890b61H ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2770 0x00007ffff6d766b4 in trans::expr::trans_rvalue_dps_unadjusted::h7c0140fcbfb13319C5A ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2771 0x00007ffff6d4afd8 in trans::expr::trans_into::h10885d95ed8d401aX6z ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2772 0x00007ffff6ccfb0f in trans::controlflow::trans_block::hfa898015a1217b0b02u ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2773 0x00007ffff6cce5b2 in trans::base::trans_closure::h8e5687f4ccb96c5eLCh ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2774 0x00007ffff6cd00eb in trans::base::trans_fn::h0bc8fb6dbe17d6adtNh ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2775 0x00007ffff6cd3c45 in trans::base::trans_item::h4f9c99b1e4474396Fbi ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2776 0x00007ffff6cd3ab9 in trans::base::trans_item::h4f9c99b1e4474396Fbi ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2777 0x00007ffff6ce156e in trans::base::trans_crate::haa02506df24d5efcF0i ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_trans-4e7c5e5c.so
#2778 0x00007ffff7af70fb in driver::phase_4_translate_to_llvm::h86d6fb84c5c936d5hOa ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_driver-4e7c5e5c.so
#2779 0x00007ffff7acefab in driver::compile_input::hb78754f2f33c01efQba ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_driver-4e7c5e5c.so
#2780 0x00007ffff7b904d2 in run_compiler::h258d36d5501c1cdfz4b ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_driver-4e7c5e5c.so
#2781 0x00007ffff7b8e123 in boxed::F.FnBox$LT$A$GT$::call_box::h7239693171334256553 ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_driver-4e7c5e5c.so
#2782 0x00007ffff7b8d65a in rt::unwind::try::try_fn::h14329119008520845439 ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_driver-4e7c5e5c.so
#2783 0x00007ffff7623ac9 in rust_try_inner ()
   from /home/pierre/.multirust/toolchains/stable/lib/libstd-4e7c5e5c.so
#2784 0x00007ffff7623ab6 in rust_try ()
   from /home/pierre/.multirust/toolchains/stable/lib/libstd-4e7c5e5c.so
#2785 0x00007ffff7b8d909 in boxed::F.FnBox$LT$A$GT$::call_box::h17332056298259451807 ()
   from /home/pierre/.multirust/toolchains/stable/lib/librustc_driver-4e7c5e5c.so
#2786 0x00007ffff75b0042 in sys::thread::create::thread_start::h490278b5c3c0b49faqv () from /home/pierre/.multirust/toolchains/stable/lib/libstd-4e7c5e5c.so
#2787 0x00007ffff1e32182 in start_thread (arg=0x7ffff03ff700)
    at pthread_create.c:312
#2788 0x00007ffff71fa47d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

@arielb1
Copy link
Contributor

arielb1 commented Jun 22, 2015

Ah well trans::_match. That code needs a rewrite, and probably also a "naïve" mode (to avoid blowups).

@tomaka
Copy link
Contributor Author

tomaka commented Jun 23, 2015

Does someone have an idea about what exactly is causing the problem? (I have absoutely no idea what trans::_match is doing and reading the code didn't help)
Too many members in the struct? Can it be caused by derive? (would implementing Clone manually solve it?)

This problem is really blocking me. Even if it gets fixed, I don't want to wait until Rust 1.3 or 1.4 is released.

@tomaka
Copy link
Contributor Author

tomaka commented Oct 13, 2015

Note that this problem is still there, but I added a work-around. If someone wants to reproduce, just remove this line and compile glium.

@jonas-schievink
Copy link
Contributor

This works with -Zorbit, so MIR trans will fix this once it's enabled by default

@andybarron
Copy link

Isn't MIR enabled by default as of Rust 1.12? And if so, can we close this?

@steveklabnik
Copy link
Member

It is, and so we probably can. @tomaka has this ICE gone away?

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. and removed C-bug Category: This is a bug. labels Jul 22, 2017
HyeonuPark added a commit to HyeonuPark/glium that referenced this issue Feb 14, 2018
with rust 1.23.0 which is stable now, this compiler stack overflow crash not occured
related to rust-lang/rust#26467
@jonas-schievink
Copy link
Contributor

glium/glium#1676 suggests this bug is gone for good now

@tomaka tomaka closed this as completed Mar 1, 2018
@tomaka
Copy link
Contributor Author

tomaka commented Mar 1, 2018

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

8 participants