Crash on Windows, Exception code: 0xc0000005 #5878

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

Projects

None yet

6 participants

@TacoSteemers

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

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
The Rust Programming Language 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

It's Windows 7.

@bblum

nominating well-covered

@pnkfelix pnkfelix was assigned Jul 30, 2013
@pnkfelix
The Rust Programming Language member

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

@vadimcn

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"
@graydon

just a bug, removing milestone/nomination.

@thadguidry

@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

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

@thadguidry

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

@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

@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

@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

@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

@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

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 added a commit that closed this issue Oct 4, 2013
@bors bors auto merge of #9662 : vadimcn/rust/package-runtime-deps, r=brson
This will make sure that system files that rust binaries depend on in Windows get packaged into stage0 snapshots as well as into Windows installer.
Currently these include `libgcc_s_dw2-1.dll`, `libstdc++-6.dll` and `libpthread-2.dll`.   Note that the latter will need to be changed to `pthreadGC2.dll` once Windows build bots get upgraded to mingw 4.0

Closes #9252
Closes #5878
Closes #9218
Closes #5712
8bb55db
@bors bors closed this in 8bb55db Oct 4, 2013
@jayanderson jayanderson pushed a commit that referenced this issue Nov 11, 2013
@bors bors auto merge of #9662 : vadimcn/rust/package-runtime-deps, r=brson
This will make sure that system files that rust binaries depend on in Windows get packaged into stage0 snapshots as well as into Windows installer.
Currently these include `libgcc_s_dw2-1.dll`, `libstdc++-6.dll` and `libpthread-2.dll`.   Note that the latter will need to be changed to `pthreadGC2.dll` once Windows build bots get upgraded to mingw 4.0

Closes #9252
Closes #5878
Closes #9218
Closes #5712
76a1fcc
@pnkfelix pnkfelix was unassigned by TacoSteemers Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment