-
Notifications
You must be signed in to change notification settings - Fork 221
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
Comments
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");
} |
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);
} |
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. |
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. |
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);
} outputIf 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 aboveuse 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 aboveCompiling 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 durka's code is next-level useful: output
|
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.
compile and execute 2.65 execute 2.20 disabled 1.69 |
That's crazy! What changes when the env var is turned on, besides the
output at the end when it crashes?
Anyway, URL parameter is lookin' pretty good...
…On Sat, Jul 29, 2017 at 5:18 PM, Jake Goulding ***@***.***> wrote:
As a datapoint, with Rust 1.19, it takes 2.48 seconds to compile and
execute "hello world" with RUST_BACKTRACE set; it takes 1.64 without.
That's almost a whole second more; 150% of the time without. I don't think
that it's reasonable yet to have this on by default.
fn main() {
println!("Hello, world!");
}
WITH:
2.65
1.91
2.56
2.37
2.68
2.60
2.45
2.57
2.53
2.43
WITHOUT
1.69
1.66
1.67
1.63
1.58
1.55
1.52
1.66
1.67
1.74
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#132 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n5SldCfQdtI2zAA9PYIWxt-VPU_Eks5sS6GwgaJpZM4M7uCz>
.
|
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 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. |
I edited my previous comment, but the short version:
|
For
execute 3.35 compile and execute 3.88 disabled 2.76 |
More numbers from directly inside the Docker container:
for i in $(seq 10); do touch src/main.rs && time env RUST_BACKTRACE=1 cargo run; done 1.132 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 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 for i in $(seq 10); do touch src/main.rs && time env cargo run; done 0.661
|
Is the old implementation faster again? Does it need to be opt-in from the end user?
The text was updated successfully, but these errors were encountered: