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

Crash on Windows, Exception code: 0xc0000005 #5878

Closed
TacoSteemers opened this issue Apr 14, 2013 · 17 comments
Closed

Crash on Windows, Exception code: 0xc0000005 #5878

TacoSteemers opened this issue Apr 14, 2013 · 17 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-windows Operating system: Windows

Comments

@TacoSteemers
Copy link

I installed using the executable from the website.

Whenever I run rustc, with or without a source file as argument, the crash with "Exception code: 0xc0000005" occurs.

Here is a copy+paste of what I found in the Windows Event Viewer.

Using gdb I get the following:

Program received signal SIGSEGV, Segmentation fault.
0x6fc5badb in libstdc++-6!_ZN9__gnu_cxx18__exchange_and_addEPVii ()
    from C:\MinGW\bin\libstdc++-6.dll
@TacoSteemers
Copy link
Author

I didn't add the backtrace, here it is:

#0  0x6fc5badb in libstdc++-6!_ZN9__gnu_cxx18__exchange_and_addEPVii ()
   from C:\MinGW\bin\libstdc++-6.dll
#1  0x6fc61052 in libstdc++-6!_ZN9__gnu_cxx9free_list8_M_clearEv ()
   from C:\MinGW\bin\libstdc++-6.dll
#2  0x6fc89eb2 in libstdc++-6!_ZNSs4_Rep10_M_disposeERKSaIcE ()
   from C:\MinGW\bin\libstdc++-6.dll
#3  0x6fc8acb4 in libstdc++-6!_ZNSs6assignERKSs () from C:\MinGW\bin\libstdc++-6.dll
#4  0x01222a5a in _fu1664___ZNSs4_Rep20_S_empty_rep_storageE ()
   from C:\Program Files (x86)\Rust\bin\rustllvm.dll
#5  0x0180654c in (anonymous namespace)::InfoOutputFilename ()
   from C:\Program Files (x86)\Rust\bin\rustllvm.dll
#6  0x01ac2e20 in ?? ()
#7  0x00891167 in DllMainCRTStartup@12 () from C:\Program Files (x86)\Rust\bin\rustllvm.dll
#8  0x76fa9950 in ntdll!RtlpNtMakeTemporaryKey () from C:\Windows\system32\ntdll.dll
#9  0x00890000 in ?? ()
#10 0x76fad8c9 in ntdll!RtlEmptyAtomTable () from C:\Windows\system32\ntdll.dll
#11 0x008910c0 in __dll_exit () from C:\Program Files (x86)\Rust\bin\rustllvm.dll
#12 0x76fb681c in ntdll!RtlStatMemoryStream () from C:\Windows\system32\ntdll.dll
#13 0x0028fd24 in ?? ()
#14 0x76fb52d6 in ntdll!TpCaptureCaller () from C:\Windows\system32\ntdll.dll
#15 0x0028fd24 in ?? ()
#16 0x76fa9e79 in ntdll!RtlpNtSetValueKey () from C:\Windows\system32\ntdll.dll
#17 0x0028fd24 in ?? ()
#18 0x00000000 in ?? ()

@pnkfelix
Copy link
Member

@TacoSteemers what version of windows is this? XP? Windows 7? Windows 8? (I'll need to set up a machine with it to replicate the bug.)

@TacoSteemers
Copy link
Author

It's Windows 7.

@bblum
Copy link
Contributor

bblum commented Jul 29, 2013

nominating well-covered

@ghost ghost assigned pnkfelix Jul 30, 2013
@pnkfelix
Copy link
Member

(assigning to self as reminder to attempt to reproduce. other devs can work-steal if idle.)

@vadimcn
Copy link
Contributor

vadimcn commented Aug 18, 2013

I'm guessing you are running rustc after a fresh mingw install?
By default mingw installs gcc 4.7, while Rust is still compiled with gcc 4.5. This causes problems because 4.7's libstdc++-6.dll is incompatible with that of gcc 4.5 (some calling convention change as I understand).
You will need to downgrade gcc back to 4.5, as described here:

mingw-get upgrade "gcc<4.6"
mingw-get upgrade "g++<4.6"

Also, you may need to downgrade your pthread library:

mingw-get upgrade "libpthread=2.8.0-3"

@vadimcn
Copy link
Contributor

vadimcn commented Aug 18, 2013

Also #5712

@graydon
Copy link
Contributor

graydon commented Aug 22, 2013

just a bug, removing milestone/nomination.

@thadguidry
Copy link
Contributor

@vadimcn Have you tested and are fairly sure that libpthread needs to be at 2.8.0-3 when using gcc 4.5 ? If so, then I can add that info to the "getting started guide".

@vadimcn
Copy link
Contributor

vadimcn commented Aug 26, 2013

@thadguidry Pretty sure, but feel free to verify independently.

@thadguidry
Copy link
Contributor

I still get this trying to compile with a 4.8.1 gcc toolchain on Windows 7. Output right before rustc.exe crashes is here: http://pastebin.mozilla.org/3022119

@vadimcn
Copy link
Contributor

vadimcn commented Sep 11, 2013

@thadguidry: You'll need to copy libgcc_s_dw2-1.dll and libstdc++-6.dll from %mingw%\bin into %rust%\build\i686-pc-mingw32\stage0\bin

@thadguidry
Copy link
Contributor

@vadimcn @brson Rather than copying, why don't we try to make it easier for everyone, and find and locate the needed dll's by somehow also adding %mingw%\bin as a default search path , perhaps with CFG_LIBDIR ?

configure: CFG_C_COMPILER := gcc
configure: CFG_LIBDIR := bin

@thadguidry
Copy link
Contributor

@vadimcn @brson Actually, the mingw-builds toolchain always has it in just the right place for us to easily pick it up:

C:\mingw-toolchains\x64-4.8.1-release-win32-sjlj-rev5\mingw64\bin

and I specify my Msys profile path as :

export PATH="/c/mingw-toolchains/x64-4.8.1-release-win32-sjlj-rev5/mingw64/bin:/user/local:$PATH"

Thoughts ?

@vadimcn
Copy link
Contributor

vadimcn commented Sep 11, 2013

@thadguidry: So does this work?
As I understand it, the issue is that there are multiple, incompatible, versions of these libraries, and in order to run a binary, it needs the same version it was linked with. So you need to have libs from gcc4.5 for stage0 compiler, and whatever toolchain version you are using for the rest.

Regarding finding them automatically:

  • I am not sure how to do this reliably. For example, after a fresh mingw installation, before you've downgraded the gcc, you may not even have them (the v4.5 libs) on your machine.
  • Do we even want to support all possible mingw permutations for everybody? I think it would be simpler to choose the version we want to jump to, create a new stage0 snapshot with that version and just tell everybody to install the right version of mingw.

@thadguidry
Copy link
Contributor

@vadimcn @brson @graydon @pnkfelix @TacoSteemers

I have updated and added new steps (Step 5) that correctly install the needed pthread libraries for Windows users of MinGW. Rust now correctly compiles Stage0, Stage1, Stage2 out of the box following the guide here: https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust

@TacoSteemers
Copy link
Author

Thanks for picking up the ticket.

It looks like I am indeed running MinGW 4.7.0, judging from the directory name "libexec\gcc\mingw32\4.7.0".
I don't recall having noticed the tutorial or the "Notes on getting started developing Rust" when I went to rust-lang.org, I simply downloaded the installer and I went from there.
I had expected that the executable covered the requirements, and I had skipped the tutorial, opting to look at other people's code instead.

A sidenote, doc/master/tutorial.html#getting-started refer to the 0.8 release which doesn't appear to be accessible yet. This is probably intentional, but I figured I'd mention it in case it isn't.

@bors bors closed this as completed in 8bb55db Oct 4, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants