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 64bit with Msys2 #97

Closed
aquynh opened this issue Sep 2, 2015 · 11 comments
Closed

Crash on Windows 64bit with Msys2 #97

aquynh opened this issue Sep 2, 2015 · 11 comments

Comments

@aquynh
Copy link
Member

aquynh commented Sep 2, 2015

I compiled latest code on Windows 64bit using Msys2 (as described in https://github.com/unicorn-engine/unicorn/blob/master/COMPILE.TXT, section 7)

After that, I run samples/sample_x83.exe -32, and this crashes immediately.

With some investigation, I found that the crash happens inside uc_emu_start(), when executing qemu_thread_join(), and the exact place is at https://github.com/unicorn-engine/unicorn/blob/master/qemu/util/qemu-thread-win32.c#L319

I searched around a bit, and think perhaps this is due to some bugs in WaitForSingleObject() of Msys2, but not entirely sure, or how to fix this.

Note that this does not happen with Windows 32bit + Msys2. Only Windows 64bit + Msys2 has this issue.

Any Windows experts can help? Thanks.

@cherepanov74
Copy link
Contributor

I can't reproduce it here. Can you share the binary and unicorn.dll file that crashes?

UPDATE: nevermind. I reproduced it

@cherepanov74
Copy link
Contributor

The actual crash happens in a different thread. And it happens here:

siglongjmp(cpu->jmp_env, 1);

@lunixbochs
Copy link
Contributor

I have a crash at this location with Python Usercorn on OS X that depends on something weird like the amount of memory allocated by Python before Unicorn is invoked. It's crazy hard to debug and I haven't found a minimal reproduction case yet. I believe the siglongjump() here is returning into the TCG generated static code buffer.

@aquynh
Copy link
Member Author

aquynh commented Sep 27, 2015

seems to get fixed, thanks!

@aquynh aquynh closed this as completed Sep 27, 2015
@aquynh
Copy link
Member Author

aquynh commented Oct 15, 2015

@cherepanov74, i can confirm that mem_apis.exe still crashes on Windows 10 64-bit, while other samples are all OK. you cannot see this if you run it from inside MSYS2 prompt, but the issue only happens when you run it from Windows command prompt.

can you try to reproduce it?

@aquynh aquynh reopened this Oct 15, 2015
@cherepanov74
Copy link
Contributor

I tried to reproduce it on Win 7 and Win 8.1 - no success so far (no crash). I'm going to try it on Win10 soon

@cherepanov74
Copy link
Contributor

I cannot reproduce it on Windows 10 64-bit

@ZakDanger
Copy link
Contributor

@aquynh your problem might be due to having a 32bit version of libglib-2.0-0.dll in your dll search path which is being incorrectly loaded. (Especially since you say it worked from msys but not the command prompt)

I just built the latest unicorn code from github using 64bit mingw-w64 on windows 10 64bit. When I first ran it it also crashed for me. Then I ran mem_apis.exe through dependency walker and I could see it was importing a 32bit version of libglib-2.0-0.dll. For me it was importing it from "C:\Program Files (x86)\Graphviz2.38\bin\libglib-2.0-0.dll".

I then copied all of the 64bit dlls mentioned in the COMPILE.TXT file into the samples dir and I no longer got any crashes.

@aquynh
Copy link
Member Author

aquynh commented Dec 4, 2015

this is interesting! so the crash is due to loading the (wrong) DLL from other unrelated app? how to prevent this problem then?

@ZakDanger
Copy link
Contributor

For me that was the cause of the crash. To fix this I just copied the correct versions of the dlls into the same directory as the sample exe files I was running. So this includes the unicorn.dll as well as the libglib etc dlls.

If copying these dlls in doesn't fix the crash for you, then your crash might be caused by something else. So you should copy them in and see if it works.

@wtdcode wtdcode closed this as completed Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants