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

RUST_BACKTRACE does not work anymore? #50138

Closed
pravic opened this issue Apr 21, 2018 · 8 comments
Closed

RUST_BACKTRACE does not work anymore? #50138

pravic opened this issue Apr 21, 2018 · 8 comments
Labels
O-windows Operating system: Windows regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@pravic
Copy link
Contributor

pravic commented Apr 21, 2018

I have noticed a backtrace absence on Windows for a while. Stable/Nightly - all the same.

Checked on:

stable-i686-pc-windows-msvc
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc

update 1: 1.24.1 works fine. How come?
update 2: CARGO_INCREMENTAL=0 has no effect on it.

Linux binaries work as expected, with respect of 0, 1, full values of the RUST_BACKTRACE.

Windows binaries print exactly the same output regardless of environment variable (excluding note):

RUST_BACKTRACE=0:

Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running target\debug\stacktrace.exe
thread 'main' panicked at 'called Option::unwrap() on a None value', libcore\option.rs:335:21
note: Run with RUST_BACKTRACE=1 for a backtrace.
error: process didn't exit successfully: target\debug\stacktrace.exe (exit code: 101)

RUST_BACKTRACE=1:

Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running target\debug\stacktrace.exe
thread 'main' panicked at 'called Option::unwrap() on a None value', libcore\option.rs:335:21
error: process didn't exit successfully: target\debug\stacktrace.exe (exit code: 101)

Dummy code to reproduce
fn bar() {
  let some: Option<bool> = None;
  some.unwrap();
}

fn foo() {
  bar();
}

fn main() {
  foo(); foo();
}
@retep998 retep998 added O-windows Operating system: Windows regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Apr 22, 2018
@pravic
Copy link
Contributor Author

pravic commented Apr 22, 2018

@dylanede
Copy link
Contributor

I'm also experiencing this.

@pravic
Copy link
Contributor Author

pravic commented Apr 24, 2018

Probably #47252 is a culprit.

@alexcrichton I am not sure which team could look on this.

@retep998
Copy link
Member

retep998 commented Apr 24, 2018

Unable to reproduce on Windows 10. Can everyone please report which version of Windows they're using?

> rustc foo.rs -g; if ($?) { .\foo.exe }
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore\option.rs:335:21
stack backtrace:
   0: std::sys::windows::backtrace::unwind_backtrace
             at C:\projects\rust\src\libstd\sys\windows\backtrace\mod.rs:65
   1: std::sys_common::backtrace::_print
             at C:\projects\rust\src\libstd\sys_common\backtrace.rs:71
   2: std::sys_common::backtrace::print
             at C:\projects\rust\src\libstd\sys_common\backtrace.rs:59
   3: std::panicking::default_hook::{{closure}}
             at C:\projects\rust\src\libstd\panicking.rs:205
   4: std::panicking::default_hook
             at C:\projects\rust\src\libstd\panicking.rs:221
   5: std::panicking::rust_panic_with_hook
             at C:\projects\rust\src\libstd\panicking.rs:457
   6: std::panicking::begin_panic_fmt
             at C:\projects\rust\src\libstd\panicking.rs:344
   7: std::panicking::rust_begin_panic
             at C:\projects\rust\src\libstd\panicking.rs:322
   8: core::panicking::panic_fmt
             at C:\projects\rust\src\libcore\panicking.rs:71
   9: core::panicking::panic
             at C:\projects\rust\src\libcore\panicking.rs:51
  10: core::option::Option<bool>::unwrap<bool>
             at C:\projects\rust\src\libcore\macros.rs:20
  11: foo::bar
             at .\foo.rs:18
  12: foo::foo
             at .\foo.rs:22
  13: foo::main
             at .\foo.rs:26
  14: std::rt::lang_start::{{closure}}<()>
             at C:\projects\rust\src\libstd\rt.rs:74
  15: std::rt::lang_start_internal::{{closure}}
             at C:\projects\rust\src\libstd\rt.rs:59
  16: std::panicking::try::do_call<closure,i32>
             at C:\projects\rust\src\libstd\panicking.rs:304
  17: panic_unwind::__rust_maybe_catch_panic
             at C:\projects\rust\src\libpanic_unwind\lib.rs:105
  18: std::panicking::try
             at C:\projects\rust\src\libstd\panicking.rs:283
  19: std::panic::catch_unwind
             at C:\projects\rust\src\libstd\panic.rs:361
  20: std::rt::lang_start_internal
             at C:\projects\rust\src\libstd\rt.rs:58
  21: std::rt::lang_start<()>
             at C:\projects\rust\src\libstd\rt.rs:74
  22: main
  23: invoke_main
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  24: __scrt_common_main_seh
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283
  25: BaseThreadInitThunk
  26: RtlUserThreadStart

> rustc -vV
rustc 1.27.0-nightly (ac3c2288f 2018-04-18)
binary: rustc
commit-hash: ac3c2288f9f9d977acb46406ba60033d65165a7b
commit-date: 2018-04-18
host: x86_64-pc-windows-msvc
release: 1.27.0-nightly
LLVM version: 6.0

@pravic
Copy link
Contributor Author

pravic commented Apr 24, 2018

Well, sure:

StackWalkEx was introduced in DbgHelp.dll 6.2.

Windows 7 SP1 has dbghelp 6.1.7601 by default. And it is not updated by VS / Tools / Debuggers / whatever. If I manually put a newer dbghelp near an executable, stacktrace prints fine.

So yes, this bug was introduced in #47252. And tests could not catch it, probably, because they are run on Windows 10 or something.

@pravic
Copy link
Contributor Author

pravic commented Apr 24, 2018

What was the point to use StackWalkEx over StackWalk64, since the former is different only by an additional flag and it is not used anyway?

upd: I see. STACKFRAME_EX gives access to the inline frame context. 😕

@pravic
Copy link
Contributor Author

pravic commented Apr 24, 2018

cc @Zoxc as the author of the change ✋

@retep998
Copy link
Member

So clearly the solution is to add the old StackWalk64 code back but as a fallback in case StackWalkEx cannot be loaded.

@retep998 retep998 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Apr 24, 2018
moxian added a commit to moxian/rust that referenced this issue May 8, 2018
PR rust-lang#47252 switched stack inspection functions of dbghelp.dll
to their newer alternatives that also capture inlined context.
Unfortunately, said new alternatives are not present in older
dbghelp.dll versions.
In particular Windows 7 at the time of writing has dbghelp.dll
version 6.1.7601 from 2010, that lacks StackWalkEx and friends.

Fixes rust-lang#50138
bors pushed a commit that referenced this issue Jun 29, 2018
PR #47252 switched stack inspection functions of dbghelp.dll
to their newer alternatives that also capture inlined context.
Unfortunately, said new alternatives are not present in older
dbghelp.dll versions.
In particular Windows 7 at the time of writing has dbghelp.dll
version 6.1.7601 from 2010, that lacks StackWalkEx and friends.

Fixes #50138
bors added a commit that referenced this issue Jun 29, 2018
Add a fallback for stacktrace printing for older Windows versions.

Some time ago we switched stack inspection functions of dbghelp.dll to their newer alternatives that also capture inlined context.
Unfortunately, said new alternatives are not present in older dbghelp.dll versions.
In particular Windows 7 at the time of writing has dbghelp.dll version 6.1.7601 from 2010, that lacks StackWalkEx and friends.

Tested on my Windows 7 - both msvc and gnu versions produce a readable stacktrace.

Fixes #50138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants