Skip to content

Application crash with debug symbols stripped out #39468

Description

@dpelevin

With current implementation of the fix for #33985, application crashes in the case of panic, if debug info is stripped out with (strip -s helloworld.exe) and RUST_BACKTRACE is set to 1.

It can be reproduced with: beta-x86_64-pc-windows-gnu - rustc 1.16.0-beta.1 (5276ba7 2017-01-31)

Activity

  1. petrochenkov commented on Feb 2, 2017

    @petrochenkov
    Contributor
  2. segevfiner commented on Feb 2, 2017

    @segevfiner
    Contributor

    I tried building the following with rustc 1.16.0-beta.1 (5276ba72e 2017-01-31) (installed via rustup):

    fn main() {
        println!("Hello, world!");
        panic!();
    }

    And stripped using strip -s from MSYS2 (up-to-date using pacman -Syu), in both debug and release, and it didn't crash for me. (Obviously printing "<unknown>" because the binary is stripped).

    Don't you love those kind of crashes? 😝

    @dpelevin Can you try and be more specific about what you did to cause this? Here are some ideas although they do sound a bit far fetched... Maybe someone else has a better idea.

    • Maybe it's dependent on your implementation of hello world?
    • Maybe it's your version of strip?
    • Maybe it's the linker used by rustc? (I think rustc always uses it's own bundled copy of gcc/ld on Windows regardless of PATH though)
    • Maybe PATH/rustup messed with you and it used some other rustc where the bug can be reproduced?
  3. petrochenkov commented on Feb 2, 2017

    @petrochenkov
    Contributor

    Hm, I think I've reproduced it.

    we@we-pc MINGW64 ~
    $ cat test.rs
    fn main() {
        println!("Hello, world!");
        panic!();
    }
    
    we@we-pc MINGW64 ~
    $ rustc --version
    rustc 1.16.0-nightly (24055d0f2 2017-01-31)
    
    we@we-pc MINGW64 ~
    $ rustc -g test.rs
    
    we@we-pc MINGW64 ~
    $ RUST_BACKTRACE=1 ./test.exe
    Hello, world!
    thread 'main' panicked at 'explicit panic', test.rs:3
    stack backtrace:
       0:           0x4288ba - std::sys::imp::backtrace::_write::he5498b02db7db530
       1:           0x432f57 - std::panicking::default_hook::{{closure}}::h67a5fa5600945646
       2:           0x432b13 - std::panicking::default_hook::hf8a9629fab063fa5
       3:           0x4334de - std::panicking::rust_panic_with_hook::hf599e44aaa8545b8
       4:           0x4015d2 - std::panicking::begin_panic::h9a6bae97ed4f65b2
                            at C:\bot\slave\nightly-dist-rustc-win-gnu-64\build\src\libstd/panicking.rs:517
       5:           0x401871 - test::main::ha6bc039bc682a0db
                            at C:\msys64\home\we/test.rs:3
       6:           0x433168 - std::panicking::try::do_call::h4c4de3903bc7c076
       7:           0x43d178 - _rust_maybe_catch_panic
       8:           0x433c83 - std::rt::lang_start::h177832d72b1c79c7
       9:           0x4018aa - main
      10:           0x4013b4 - _tmainCRTStartup
      11:           0x4014e7 - mainCRTStartup
      12:     0x7ffc73cf13d1 - unit_addrs_search
    
    we@we-pc MINGW64 ~
    $ which strip
    /c/mingw-w64/x86_64-6.2.0-win32-seh-rt_v5-rev1/mingw64/bin/strip
    
    we@we-pc MINGW64 ~
    $ strip ./test.exe
    
    we@we-pc MINGW64 ~
    $ RUST_BACKTRACE=1 ./test.exe
    Hello, world!
    thread 'main' panicked at 'explicit panic', test.rs:3
    stack backtrace:
    
    we@we-pc MINGW64 ~
    $ RUST_BACKTRACE=1 gdb ./test.exe
    GNU gdb (GDB) 7.9
    Copyright (C) 2015 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "x86_64-pc-msys".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
    ImportError: No module named libstdcxx.v6.printers
    /etc/gdbinit:6: Error in sourced command file:
    Error while executing Python code.
    Reading symbols from ./test.exe...(no debugging symbols found)...done.
    (gdb) run
    Starting program: /home/we/test.exe
    [New Thread 6068.0x126c]
    Hello, world!
    thread 'main' panicked at 'explicit panic', test.rs:3
    stack backtrace:
    warning: Critical error detected c0000374
    
    Program received signal SIGTRAP, Trace/breakpoint trap.
    0x00007ffc74361b30 in ntdll!RtlpNtMakeTemporaryKey () from /c/Windows/SYSTEM32/ntdll.dll
    (gdb) c
    Continuing.
    gdb: unknown target exception 0xc0000374 at 0x7ffc74361b70
    
    Program received signal ?, Unknown signal.
    0x00007ffc74361b70 in ntdll!RtlpNtMakeTemporaryKey () from /c/Windows/SYSTEM32/ntdll.dll
    (gdb) c
    Continuing.
    [Inferior 1 (process 6068) exited with code 030000001564]
    (gdb) q
    
    
  4. dpelevin commented on Feb 2, 2017

    @dpelevin
    Author
    1. Here is the HelloWorld I can reproduce problem with: https://github.com/dpelevin/helloworld

    2. I've uploaded strip.exe I was using: https://github.com/dpelevin/helloworld/tree/master/misc
      C:\MinGW\bin>strip.exe --version
      GNU strip (GNU Binutils) 2.24
      Copyright 2013 Free Software Foundation, Inc.
      This program is free software; you may redistribute it under the terms of
      the GNU General Public License version 3 or (at your option) any later version.
      This program has absolutely no warranty.

    3. I have the same MinGW version in the PATH as Rust uses:
      C:\MinGW\bin>ld.exe --version
      GNU ld (GNU Binutils) 2.24
      Copyright 2013 Free Software Foundation, Inc.
      This program is free software; you may redistribute it under the terms of
      the GNU General Public License version 3 or (at your option) a later version.
      This program has absolutely no warranty.
      C:\MinGW\bin>gcc.exe --version
      gcc.exe (x86_64-posix-seh-rev3, Built by MinGW-W64 project) 4.9.1
      Copyright (C) 2014 Free Software Foundation, Inc.
      This is free software; see the source for copying conditions. There is NO
      warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    Additionally I've renamed C:\MinGW to C:\MinGW_ to remove it from PATH and the problem were still in place.

    1. I've tried to reinstall beta version:
      rustup toolchain remove beta-x86_64-pc-windows-gnu
      ...
      rustup toolchain install beta-x86_64-pc-windows-gnu
      ....
      beta-x86_64-pc-windows-gnu installed - rustc 1.16.0-beta.1 (5276ba7 2017-01-31)
      rustup default beta-gnu
      ...
      beta-x86_64-pc-windows-gnu unchanged - rustc 1.16.0-beta.1 (5276ba7 2017-01-31)

    Still crashes.

    UPD: Look like you've already caught it :)

  5. segevfiner commented on Feb 3, 2017

    @segevfiner
    Contributor

    @petrochenkov
    It looks like heap corruption (STATUS_HEAP_CORRUPTION - 0xC0000374)
    You can try application verifier on the executable (Win+R appverif.exe if you have some Windows SDK installed), it is often able to break on the error exactly , but I'm not sure how well it works with GNU stuff.

    Sadly it still doesn't reproduce on my machine, so I can't debug myself. 😞
    Some other stuff I can think of that might be the reason why it doesn't reproduce on my computer:
    I'm on Windows 10.0.14393.693 64-bit
    I don't have any dbghelp.dll on PATH besides the one in C:\Windows\System32

  6. petrochenkov commented on Feb 3, 2017

    @petrochenkov
    Contributor

    Usual free(uninitialized_pointer), move along, nothing to see here.
    Fixed in #39509

  7. brson commented on Feb 3, 2017

    @brson
    Contributor

    cc @fitzgen libbacktrace crash

  8. added 3 commits that reference this issue on Feb 5, 2017
  9. added a commit that references this issue on Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions