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

Re-enable RUST_BACKTRACE #132

Closed
shepmaster opened this issue Apr 12, 2017 · 11 comments
Closed

Re-enable RUST_BACKTRACE #132

shepmaster opened this issue Apr 12, 2017 · 11 comments
Labels
enhancement Something new the playground could do

Comments

@shepmaster
Copy link
Member

Is the old implementation faster again? Does it need to be opt-in from the end user?

@shepmaster shepmaster added enhancement Something new the playground could do help wanted Not immediately going to be prioritized — ask for mentoring instructions! question labels Apr 12, 2017
@ghost
Copy link

ghost commented Jul 16, 2017

example workaround:

use std::env;

fn main() {
    env::set_var("RUST_BACKTRACE", "1");

    let one_plus_one = stringify!(1 + a);
    assert_eq!(one_plus_one, "1 + 1");
}

@durka
Copy link

durka commented Jul 25, 2017

Workaround isn't enough for compiler ICEs. It was opt-in on the old official playground. Why not just bring back the URL query param?

Edit: here's the completed workaround, but the query param is still much better:

use std::io::Write;
use std::fs::File;
use std::process::Command;

fn main() {
    let code = stringify!(
        trait VecN {
            const DIM: usize;
        }
        trait Mat {
            type Row: VecN;
        }
        
        fn m<M: Mat>() {
            let x = M::Row::DIM;
        }
        fn main() {
        }
    );
    
    writeln!(File::create("foo.rs").unwrap(), "{}", code).unwrap();
    
    let cmd = Command::new("rustc")
        .env("RUST_BACKTRACE", "1")
        .arg("+nightly")
        .arg("foo.rs")
        .status().unwrap();
    println!("exit code {}", cmd);
}

@RalfJung
Copy link
Member

Ideally, there'd also be a way to discover that param somewhere. Like, detect if the output suggests to turn on RUST_BACKTRACE, then add a link somewhere which has the param set.

@ghost
Copy link

ghost commented Jul 25, 2017

Would something like this make sense? for setting env var(s):

// env: RUST_BACKTRACE=1
// env: SOMETHINGELSE=whatever whenever assuming data until end of line
// //env: CC=/usr/bin/cc
// ^ commented out env aka not in effect
fn main() {
    let one_plus_one = stringify!(1 + a);
    assert_eq!(one_plus_one, "1 + 1");
}

Assuming they were parsed from the above and set before running the compiler.
Or could that be a potential security issue? if user could set any env var.
Or is it too complicated/messy to want it implemented?

@ghost
Copy link

ghost commented Jul 29, 2017

Example ICE that I just stumbled upon(but was already found by others), re durka's comment:

pub const X: i64 = std::i64::MAX + 1;
fn main() {
    println!("{}", X);
}

(^ playground link)

output
Compiling playground v0.0.1 (file:///playground) warning: constant evaluation error: attempt to add with overflow. This will become a HARD ERROR in the future --> src/main.rs:1:20 | 1 | pub const X: i64 = std::i64::MAX + 1; | ^^^^^^^^^^^^^^^^^ | = note: #[warn(const_err)] on by default

error[E0080]: constant evaluation error
--> src/main.rs:1:20
|
1 | pub const X: i64 = std::i64::MAX + 1;
| ^^^^^^^^^^^^^^^^^ attempt to add with overflow

error: internal compiler error: /checkout/src/librustc_trans/mir/constant.rs:396: _1 not initialized
--> src/main.rs:3:20
|
3 | println!("{}", X);
| ^

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-nightly (52a330969 2017-07-27) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box', /checkout/src/librustc_errors/lib.rs:438:8
note: Run with RUST_BACKTRACE=1 for a backtrace.

error: Could not compile playground.

To learn more, run the command again with --verbose.

If someone knows how to make github wrap long lines in the above output, please let me know.

playground link for this ICE with durka's workaround for displaying ICE stacktraces - thank you btw!

code for the above
use std::io::Write;
use std::fs::File;
use std::process::Command;

fn main() {
    let code = stringify!(
        pub const X: i64 = std::i64::MAX + 1;
fn main() {
    println!("{}", X);
}

    );

    writeln!(File::create("foo.rs").unwrap(), "{}", code).unwrap();

    let cmd = Command::new("rustc")
        .env("RUST_BACKTRACE", "full")
        .arg("+nightly")
        .arg("foo.rs")
        .status()
        .unwrap();
    println!("exit code {}", cmd);
}
output for the above
   Compiling playground v0.0.1 (file:///playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.86 secs
     Running `target/debug/playground`
warning: constant evaluation error: attempt to add with overflow. This will become a HARD ERROR in the future
 --> foo.rs:1:21
  |
1 | pub const X : i64 = std :: i64 :: MAX + 1 ; fn main (  ) {
  |                     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(const_err)] on by default

error[E0080]: constant evaluation error
--> foo.rs:1:21
|
1 | pub const X : i64 = std :: i64 :: MAX + 1 ; fn main ( ) {
| ^^^^^^^^^^^^^^^^^^^^^ attempt to add with overflow

error: internal compiler error: /checkout/src/librustc_trans/mir/constant.rs:396: _1 not initialized
--> foo.rs:2:20
|
2 | println ! ( "{}" , X ) ; }
| ^

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-nightly (52a330969 2017-07-27) running on x86_64-unknown-linux-gnu

note: run with RUST_BACKTRACE=1 for a backtrace

thread 'rustc' panicked at 'Box', /checkout/src/librustc_errors/lib.rs:438:8
stack backtrace:
0: 0x7f0cbc947db3 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h1e2c58aa3ff6d86d
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: 0x7f0cbc942494 - std::sys_common::backtrace::_print::h021c974b848276a0
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: 0x7f0cbc955c33 - std::panicking::default_hook::{{closure}}::heee72575d0ec5077
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:380
3: 0x7f0cbc955928 - std::panicking::default_hook::hfd71e7dd65b0a86c
at /checkout/src/libstd/panicking.rs:390
4: 0x7f0cbc956137 - std::panicking::rust_panic_with_hook::h4eba8d7e50a7fffa
at /checkout/src/libstd/panicking.rs:610
5: 0x7f0cbb84f878 - std::panicking::begin_panic::h48e4cf472e4fad07
6: 0x7f0cbb87b668 - rustc::session::opt_span_bug_fmt::{{closure}}::haf7ee303771aa9d5
7: 0x7f0cbb87b4c7 - rustc::session::span_bug_fmt::haa62c77dec292770
8: 0x7f0cbb91a0f3 - rustc_trans::mir::constant::MirConstContext::const_lvalue::h1dbacf146fcd1592
9: 0x7f0cbb91aeec - rustc_trans::mir::constant::MirConstContext::const_rvalue::h1269edfb1e998250
10: 0x7f0cbb91898c - rustc_trans::mir::constant::MirConstContext::trans::hfa9f803bd5275c21
11: 0x7f0cbb91e7bf - rustc_trans::mir::constant::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_constant::h5da8b49ad7fff201
12: 0x7f0cbb921fa1 - rustc_trans::mir::operand::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_operand::hec9f10a4034bfc20
13: 0x7f0cbb923684 - rustc_trans::mir::rvalue::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_rvalue_operand::h865cdcdd7c0b92cf
14: 0x7f0cbb90c713 - rustc_trans::mir::trans_mir::h559e0cace6be4e5a
15: 0x7f0cbb92ff33 - rustc_trans::trans_item::TransItem::define::h8e122b431d2e3ba3
16: 0x7f0cbb8d4bed - rustc_trans::base::trans_crate::module_translation::hc4a2a7b27dcd9f96
17: 0x7f0cbb8cecfe - rustc_trans::base::trans_crate::h15091f3336a483e1
18: 0x7f0cbcd02902 - rustc_driver::driver::phase_4_translate_to_llvm::h911c0cc67ac5141c
19: 0x7f0cbcccf79a - rustc_driver::driver::compile_input::{{closure}}::h81c7e0ebddde0b7a
20: 0x7f0cbcd0174e - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::hea490b5adce91e62
21: 0x7f0cbcce3823 - rustc_driver::driver::phase_3_run_analysis_passes::h1210be0da5a54c32
22: 0x7f0cbcccdb30 - rustc_driver::driver::compile_input::hbf08f2b62431a302
23: 0x7f0cbcd12f65 - rustc_driver::run_compiler::h7b5ef3de0e76a53e
24: 0x7f0cbcc2c477 - std::sys_common::backtrace::__rust_begin_short_backtrace::he953d71f28957e91
25: 0x7f0cbc98567c - __rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:98
26: 0x7f0cbcc63e60 - <F as alloc::boxed::FnBox>::call_box::hb0c50b1ae5590427
27: 0x7f0cbc954b2b - std::sys::imp::thread::Thread::new::thread_start::h8cc7df731d74d00c
at /checkout/src/liballoc/boxed.rs:692
at /checkout/src/libstd/sys_common/thread.rs:21
at /checkout/src/libstd/sys/unix/thread.rs:84
28: 0x7f0cb7aec6b9 - start_thread
29: 0x7f0cbc6023dc - clone
30: 0x0 -

Standard Output
exit code exit code: 101


durka's code is next-level useful:
for also setting RUST_LOG env var, check this playground

output
   Compiling playground v0.0.1 (file:///playground)
    Finished dev [unoptimized + debuginfo] target(s) in 1.23 secs
     Running `target/debug/playground`
INFO:rustc_metadata::creader: resolving crate `extern crate std as std`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-53ea3d304236e3cd.rlib
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-fecbcef5e03d3ec3.rlib
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-53ea3d304236e3cd.so
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-53ea3d304236e3cd.rlib
INFO:rustc_metadata::locator: reading "libstd-53ea3d304236e3cd.rlib" => Duration { secs: 0, nanos: 289913 }
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-fecbcef5e03d3ec3.rlib
INFO:rustc_metadata::locator: reading "libstd_unicode-fecbcef5e03d3ec3.rlib" => Duration { secs: 0, nanos: 46947 }
INFO:rustc_metadata::locator: Rejecting via crate name
INFO:rustc_metadata::locator: metadata mismatch
INFO:rustc_metadata::creader: register crate `extern crate std as std`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f6bafd9150566103.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f6bafd9150566103.rlib
INFO:rustc_metadata::locator: reading "libcore-f6bafd9150566103.rlib" => Duration { secs: 0, nanos: 54572 }
INFO:rustc_metadata::creader: register crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate rand as rand`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-469e081e7b55328b.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-469e081e7b55328b.rlib
INFO:rustc_metadata::locator: reading "librand-469e081e7b55328b.rlib" => Duration { secs: 0, nanos: 81250 }
INFO:rustc_metadata::creader: register crate `extern crate rand as rand`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc as alloc`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-20278a1d925c78bf.rlib
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-88f9ab556e433eab.rlib
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fdc9c5484bdb6d20.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fdc9c5484bdb6d20.rlib
INFO:rustc_metadata::locator: reading "liballoc-fdc9c5484bdb6d20.rlib" => Duration { secs: 0, nanos: 76382 }
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-20278a1d925c78bf.rlib
INFO:rustc_metadata::locator: reading "liballoc_jemalloc-20278a1d925c78bf.rlib" => Duration { secs: 0, nanos: 323667 }
INFO:rustc_metadata::locator: Rejecting via crate name
INFO:rustc_metadata::locator: metadata mismatch
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-88f9ab556e433eab.rlib
INFO:rustc_metadata::locator: reading "liballoc_system-88f9ab556e433eab.rlib" => Duration { secs: 0, nanos: 41144 }
INFO:rustc_metadata::locator: Rejecting via crate name
INFO:rustc_metadata::locator: metadata mismatch
INFO:rustc_metadata::creader: register crate `extern crate alloc as alloc`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate std_unicode as std_unicode`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-fecbcef5e03d3ec3.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-fecbcef5e03d3ec3.rlib
INFO:rustc_metadata::locator: reading "libstd_unicode-fecbcef5e03d3ec3.rlib" => Duration { secs: 0, nanos: 81238 }
INFO:rustc_metadata::creader: register crate `extern crate std_unicode as std_unicode`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate std_unicode as std_unicode`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc_system as alloc_system`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-88f9ab556e433eab.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-88f9ab556e433eab.rlib
INFO:rustc_metadata::locator: reading "liballoc_system-88f9ab556e433eab.rlib" => Duration { secs: 0, nanos: 68327 }
INFO:rustc_metadata::creader: register crate `extern crate alloc_system as alloc_system`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc as alloc`
INFO:rustc_metadata::creader: resolving crate `extern crate std_unicode as std_unicode`
INFO:rustc_metadata::creader: resolving crate `extern crate libc as libc`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-9655cd2c7100edd5.rlib
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-28ca2c90143aab16.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-28ca2c90143aab16.rlib
INFO:rustc_metadata::locator: reading "liblibc-28ca2c90143aab16.rlib" => Duration { secs: 0, nanos: 48831 }
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-9655cd2c7100edd5.rlib
INFO:rustc_metadata::locator: reading "liblibc-9655cd2c7100edd5.rlib" => Duration { secs: 0, nanos: 44132 }
INFO:rustc_metadata::locator: Rejecting via hash: expected 0718f94ff5257ed6 got 64ec7ce533df6a96
INFO:rustc_metadata::locator: metadata mismatch
INFO:rustc_metadata::creader: register crate `extern crate libc as libc`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate libc as libc`
INFO:rustc_metadata::creader: resolving crate `extern crate unwind as unwind`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-eebd9a32393d457e.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-eebd9a32393d457e.rlib
INFO:rustc_metadata::locator: reading "libunwind-eebd9a32393d457e.rlib" => Duration { secs: 0, nanos: 43320 }
INFO:rustc_metadata::creader: register crate `extern crate unwind as unwind`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate libc as libc`
INFO:rustc_metadata::creader: resolving crate `extern crate compiler_builtins as compiler_builtins`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f2b80b64797b4af9.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f2b80b64797b4af9.rlib
INFO:rustc_metadata::locator: reading "libcompiler_builtins-f2b80b64797b4af9.rlib" => Duration { secs: 0, nanos: 178428 }
INFO:rustc_metadata::creader: register crate `extern crate compiler_builtins as compiler_builtins`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc_jemalloc as alloc_jemalloc`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-20278a1d925c78bf.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-20278a1d925c78bf.rlib
INFO:rustc_metadata::locator: reading "liballoc_jemalloc-20278a1d925c78bf.rlib" => Duration { secs: 0, nanos: 333009 }
INFO:rustc_metadata::creader: register crate `extern crate alloc_jemalloc as alloc_jemalloc`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc as alloc`
INFO:rustc_metadata::creader: resolving crate `extern crate std_unicode as std_unicode`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc_system as alloc_system`
INFO:rustc_metadata::creader: resolving crate `extern crate libc as libc`
INFO:rustc_metadata::creader: resolving crate `extern crate panic_unwind as panic_unwind`
INFO:rustc_metadata::creader: falling back to a load
INFO:rustc_metadata::locator: lib candidate: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-4741a102ac3c6cbe.rlib
INFO:rustc_metadata::locator: rlib reading metadata from: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-4741a102ac3c6cbe.rlib
INFO:rustc_metadata::locator: reading "libpanic_unwind-4741a102ac3c6cbe.rlib" => Duration { secs: 0, nanos: 45274 }
INFO:rustc_metadata::creader: register crate `extern crate panic_unwind as panic_unwind`
INFO:rustc_metadata::creader: resolving crate `extern crate core as core`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc as alloc`
INFO:rustc_metadata::creader: resolving crate `extern crate std_unicode as std_unicode`
INFO:rustc_metadata::creader: resolving crate `extern crate libc as libc`
INFO:rustc_metadata::creader: resolving crate `extern crate unwind as unwind`
INFO:rustc_metadata::creader: resolving crate `extern crate alloc_jemalloc as alloc_jemalloc`
INFO:rustc_metadata::creader: injecting a dep from 1 to 11
INFO:rustc_metadata::creader: panic runtime not found -- loading panic_unwind
INFO:rustc_metadata::creader: resolving crate `extern crate panic_unwind as panic_unwind`
INFO:rustc_metadata::creader: injecting a dep from 1 to 11
INFO:rustc_metadata::creader: resolved crates:
INFO:rustc_metadata::creader:   name: panic_unwind
INFO:rustc_metadata::creader:   cnum: 11
INFO:rustc_metadata::creader:   hash: 0f029d3705d9be9b
INFO:rustc_metadata::creader:   reqd: Implicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-4741a102ac3c6cbe.rlib
INFO:rustc_metadata::creader:   name: unwind
INFO:rustc_metadata::creader:   cnum: 8
INFO:rustc_metadata::creader:   hash: 2e82914a34d4b7d5
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-eebd9a32393d457e.rlib
INFO:rustc_metadata::creader:   name: std_unicode
INFO:rustc_metadata::creader:   cnum: 5
INFO:rustc_metadata::creader:   hash: 80559d2f15f9789f
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-fecbcef5e03d3ec3.rlib
INFO:rustc_metadata::creader:   name: core
INFO:rustc_metadata::creader:   cnum: 2
INFO:rustc_metadata::creader:   hash: ccae72e3593c4519
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f6bafd9150566103.rlib
INFO:rustc_metadata::creader:   name: alloc_jemalloc
INFO:rustc_metadata::creader:   cnum: 10
INFO:rustc_metadata::creader:   hash: 804ba91213a156d3
INFO:rustc_metadata::creader:   reqd: Implicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-20278a1d925c78bf.rlib
INFO:rustc_metadata::creader:   name: libc
INFO:rustc_metadata::creader:   cnum: 7
INFO:rustc_metadata::creader:   hash: 0718f94ff5257ed6
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-28ca2c90143aab16.rlib
INFO:rustc_metadata::creader:   name: alloc
INFO:rustc_metadata::creader:   cnum: 4
INFO:rustc_metadata::creader:   hash: 30c80bc463a7b7c5
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fdc9c5484bdb6d20.rlib
INFO:rustc_metadata::creader:   name: std
INFO:rustc_metadata::creader:   cnum: 1
INFO:rustc_metadata::creader:   hash: 8bced19bf27e9263
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:   dylib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-53ea3d304236e3cd.so
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-53ea3d304236e3cd.rlib
INFO:rustc_metadata::creader:   name: compiler_builtins
INFO:rustc_metadata::creader:   cnum: 9
INFO:rustc_metadata::creader:   hash: bbaf00045277b763
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f2b80b64797b4af9.rlib
INFO:rustc_metadata::creader:   name: alloc_system
INFO:rustc_metadata::creader:   cnum: 6
INFO:rustc_metadata::creader:   hash: 10f5da3d8cfc1c3a
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-88f9ab556e433eab.rlib
INFO:rustc_metadata::creader:   name: rand
INFO:rustc_metadata::creader:   cnum: 3
INFO:rustc_metadata::creader:   hash: 80dd380a97bf0a1d
INFO:rustc_metadata::creader:   reqd: Explicit
INFO:rustc_metadata::creader:    rlib: /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-469e081e7b55328b.rlib
warning: constant evaluation error: attempt to add with overflow. This will become a HARD ERROR in the future
 --> foo.rs:1:21
  |
1 | pub const X : i64 = 2 + std :: i64 :: MAX ; fn main (  ) {
  |                     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(const_err)] on by default

INFO:rustc_metadata::cstore: topological ordering: [CrateNum(2), CrateNum(5), CrateNum(4), CrateNum(7), CrateNum(8), CrateNum(11), CrateNum(6), CrateNum(10), CrateNum(3), CrateNum(9), CrateNum(1)]
INFO:rustc_trans::back::link: LinkMeta { crate_hash: Svh { hash: 16472872479388106548 } }
INFO:rustc::traits::trans: Cache miss: Binder(<i64 as std::fmt::Display>) => VtableImpl(impl_def_id=DefId { krate: CrateNum(2), node: DefIndex(17297) => core/82d513d::fmt[0]::num[0]::{{impl}}[93] }, substs=Slice([]), nested=[])
INFO:rustc_trans::base: trans_instance(std::fmt::ArgumentV1::new::<i64>)
INFO:rustc_trans::base: trans_instance(std::fmt::Arguments::new_v1)
INFO:rustc_trans::base: trans_instance(main)
error[E0080]: constant evaluation error
 --> foo.rs:1:21
  |
1 | pub const X : i64 = 2 + std :: i64 :: MAX ; fn main (  ) {
  |                     ^^^^^^^^^^^^^^^^^^^^^ attempt to add with overflow

error: internal compiler error: /checkout/src/librustc_trans/mir/constant.rs:396: _1 not initialized
 --> foo.rs:2:20
  |
2 | println ! ( "{}" , X ) ; }
  |                    ^

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-nightly (52a330969 2017-07-27) running on x86_64-unknown-linux-gnu

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

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:438:8
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 /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:380
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:390
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:610
   5: std::panicking::begin_panic
   6: rustc::session::opt_span_bug_fmt::{{closure}}
   7: rustc::session::span_bug_fmt
   8: rustc_trans::mir::constant::MirConstContext::const_lvalue
   9: rustc_trans::mir::constant::MirConstContext::const_rvalue
  10: rustc_trans::mir::constant::MirConstContext::trans
  11: rustc_trans::mir::constant::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_constant
  12: rustc_trans::mir::operand::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_operand
  13: rustc_trans::mir::rvalue::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_rvalue_operand
  14: rustc_trans::mir::trans_mir
  15: rustc_trans::trans_item::TransItem::define
  16: rustc_trans::base::trans_crate::module_translation
  17: rustc_trans::base::trans_crate
  18: rustc_driver::driver::phase_4_translate_to_llvm
  19: rustc_driver::driver::compile_input::{{closure}}
  20: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  21: rustc_driver::driver::phase_3_run_analysis_passes
  22: rustc_driver::driver::compile_input
  23: rustc_driver::run_compiler

Standard Output
Pre-trans
Ty interner             total           ty region  both
    TyAdt             :    383 63.5%,  0.0%   0.0%  0.0%
    TyArray           :      3  0.5%,  0.0%   0.0%  0.0%
    TySlice           :     10  1.7%,  0.0%   0.0%  0.0%
    TyRawPtr          :      4  0.7%,  0.0%   0.0%  0.0%
    TyRef             :    155 25.7%,  0.2%   0.0%  0.0%
    TyFnDef           :     13  2.2%,  0.2%   0.0%  0.0%
    TyFnPtr           :      4  0.7%,  0.0%   0.0%  0.0%
    TyDynamic         :      0  0.0%,  0.0%   0.0%  0.0%
    TyClosure         :      0  0.0%,  0.0%   0.0%  0.0%
    TyTuple           :      4  0.7%,  0.0%   0.0%  0.0%
    TyParam           :     22  3.6%,  0.0%   0.0%  0.0%
    TyInfer           :      4  0.7%,  0.7%   0.0%  0.0%
    TyProjection      :      1  0.2%,  0.0%   0.0%  0.0%
    TyAnon            :      0  0.0%,  0.0%   0.0%  0.0%
                  total    603         1.0%   0.0%  0.0%
Substs interner: #282
Region interner: #212
Stability interner: #2
Layout interner: #0
exit code exit code: 101

@shepmaster
Copy link
Member Author

shepmaster commented Jul 29, 2017

RUST_BACKTRACE time (seconds)
compile and execute 2.48
execute 2.02
disabled 1.64

That's almost a whole second more if it's always enabled; 150% of the time when it's disabled. I don't think that it's reasonable to have this on by default yet.

  • Rust 1.19
  • Time reported by the Chrome network tools for the full request
  • Running on my laptop
  • The code:
    fn main() {
        println!("Hello, world!");
    }

compile and execute

2.65
1.91
2.56
2.37
2.68
2.60
2.45
2.57
2.53
2.43

execute
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='env RUST_BACKTRACE=1'

2.20
1.98
2.05
2.02
2.10
2.05
2.09
1.91
1.87
1.96

disabled

1.69
1.66
1.67
1.63
1.58
1.55
1.52
1.66
1.67
1.74

@durka
Copy link

durka commented Jul 29, 2017 via email

@shepmaster
Copy link
Member Author

What changes when the env var is turned on, besides the
output at the end when it crashes?

I don't fully know. It's much better than the 10-20 seconds that used to be added.

An intermediate solution (that would likely require some rearchitecting in the sandbox) would be to split the beautiful cargo run command into cargo build and then cargo run (or run the program directly?). It's my hope that it's the fact it's set during compilation that causes the problem.

Having the backtrace on user code makes for a much nicer user experience; I'm not that worried about making ICEs easier to debug by default; that could live as a config option.

@shepmaster
Copy link
Member Author

I edited my previous comment, but the short version:

RUST_BACKTRACE time (seconds)
compile and execute 2.48
execute 2.02
disabled 1.64

@shepmaster
Copy link
Member Author

For rustc 1.20.0-nightly (15aa15b03 2017-07-21):

RUST_BACKTRACE time (seconds)
compile and execute 4.19
execute 3.31
disabled 2.99

execute

3.35
3.21
3.28
3.08
3.37
3.41
3.09
3.25
3.58
3.44

compile and execute

3.88
4.22
4.35
3.95
4.07
3.83
4.35
4.30
4.51
4.43

disabled

2.76
2.81
2.89
3.16
2.98
3.08
3.03
2.99
3.08
3.07

@shepmaster
Copy link
Member Author

shepmaster commented Jul 30, 2017

More numbers from directly inside the Docker container:

time (seconds)
RUST_BACKTRACE=1 cargo run 1.159
env RUST_BACKTRACE=1 cargo build; ./target/debug/playground 1.214
cargo build; env RUST_BACKTRACE=1 ./target/debug/playground 0.676
cargo run 0.672

for i in $(seq 10); do touch src/main.rs && time env RUST_BACKTRACE=1 cargo run; done

1.132
1.161
1.124
1.140
1.129
1.157
1.146
1.201
1.212
1.184

for i in $(seq 10); do touch src/main.rs && time bash -c 'env RUST_BACKTRACE=1 cargo build; ./target/debug/playground'; done

1.199
1.212
1.165
1.199
1.242
1.201
1.234
1.233
1.231
1.223

for i in $(seq 10); do touch src/main.rs && time bash -c 'cargo build; env RUST_BACKTRACE=1 ./target/debug/playground'; done

0.657
0.652
0.671
0.675
0.656
0.668
0.659
0.661
0.761
0.695

for i in $(seq 10); do touch src/main.rs && time env cargo run; done

0.661
0.637
0.655
0.644
0.649
0.674
0.663
0.708
0.716
0.714

 rustc -vV
rustc 1.19.0 (0ade33941 2017-07-17)
binary: rustc
commit-hash: 0ade339411587887bf01bcfa2e9ae4414c8900d4
commit-date: 2017-07-17
host: x86_64-unknown-linux-gnu
release: 1.19.0
LLVM version: 4.0

@shepmaster shepmaster removed help wanted Not immediately going to be prioritized — ask for mentoring instructions! question labels Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something new the playground could do
Projects
None yet
Development

No branches or pull requests

3 participants