-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
libffi:x86-windows crashes since update to version 3.3 on february 7th #10230
Comments
I'm also having a similar issue but with GTK in a 64bit build: OS: Windows 10 x64 Everything works fine in a release build, but when running a debug build I get a runtime error as soon as the application starts up. |
Having the same issue here when using Gtk |
Any updates on this? This is a complete blocker for debugging my application |
Hi all, |
@NancyLi1013 how can i install the older library version? |
You can use Could you please also help provide the project case? |
If you don't need to debug libffi then you can use the release build of it. That's what I did for now, just copied the release version and overwrote it in my app's output directory |
This may be helpful in your actual painful situation. But it will not help to fix the general problem.
|
Here are two minimal example applications to reproduce the behavior. One is for gtk, the other one is for gtkmm. The msvs vcxproj... and props files provided with the two examples allow you to test debug and release builds for 32 and 64 bit windows. You should unpack the two zip files to the directory where your vcpkg directory resides. this will lead to a directory layout like that:
The GtkmmSample presupposes, that you vcpkg install gtkmm for the target platforms you want to build and test. To build and test the GtkSample only vcpkg install gtk is needed. I've tested all variants with both libffi 3.3 (commit 7d4227f) and libffi 3.1 (the commit immediately before 8eaa597). Hope this helps solving the issue. |
Thanks for your update and detail information about this issue. |
@rglbssw |
@NancyLi1013 yes it only happens in debug builds as @itayzafrir mentioned. Great you can reproduce this now! |
@NancyLi1013 it seems that in x86-windows debug mode, in function ffi_call_int, call to _alloca leads to a failure in _RTC_CheckStackVars2, because %rsp is recovered when the ffi_call_int function return, which is after call to _RTC_CheckStackVars2. avoid using _alloca can help. |
@764994703 |
I think that's a Visual Studio bug. |
Following the suggestions of @rglbssw and @NancyLi1013 I checkout to the commit tagged 2020.01 where libffi:x64-windows 3.1-7 is installed. I do confirm that the .exe executes normally in debug mode with this version of the library. In the older version libbffi was installed as a static library only (and so there is no export of the dll into the application's directory), whereas in the newer version 3.3-2 libffi is installed as both static and dynamic. May be a workaround would be to compile libffi 3.3-2 as a static lib only ? |
Allowing shared DLL is needed because vcpkg only supports dynamic DLL on Windows ARM. (insane, I know) We should be able to let it build only static lib on x86/x64. |
Yep, experiencing the same issue. Had to run my College Project in release mode to avoid this. The libffi call is optimized away in release mode (resulting in a lot less assembly code) and also does not corrupt the stack. Maybe a memory allocation / re-allocation issue as @764994703 said.. I gave up trying to figure out the root cause... glad I found this thread !! |
@NancyLi1013 just checked on my own project - all works fine! |
Works fine for x64-windows. I tried to extend the solution for x86-windows (see #12498 (comment)). |
[Newbie Question]: Shouldn't we find out what caused the Stack Corruption instead of disabling the Runtime Check? I don't mean to offend / belittle the work done by @Mixaill and @rglbssw , but I would like to know what caused the Stack to be corrupted in the first place. According to Microsoft Docs, one of the reasons /RTC fails is due to a calling convention mismatch. I have tried setting different calling conventions like _stdcall or _cdecl , but the crash persists. The other reasons include overruns / under-runs of memory; Padding issues with Struct Member Alignment ( /Zp ), which I am currently looking into.. |
@Ajax-Light It's a Visual Studio bug. |
It is the intended behavior for libffi, it modfies stack of the caller function which results in RTC trigger. No actual error here. |
Ah! I understand now. Thanks for your time. 👍 |
Thanks to all at any place! (... e grazie a la @strega-nil) |
Seems as if the patch was not applied already. The code would look a bit different, if it was. |
Have installed with gtkmm as root package. Same issue. x64-windows. |
Describe the bug
I install gtkmm:x86-windows for use in an application. everything worked fine. But with commit 7d4227f libffi was upgraded to version 3.3. Since then my application crashes on every mouse click when returning from libffi assembler code (see debugger screenshot under "Failure Logs" below).
I assume, it has to do with the target x86-windows. The libffi src folder does not contain a "win32.S" file any more, only a "win64.S"!
Environment
To Reproduce
Steps to reproduce the behavior:
I think it does not depend on gtkmm. I'm sure, a GTK3-application would also crash.
Expected behavior
I would expect no crash. This was the behaviour with libffi 3.1
Failure logs
Debugger screenshot
Additional context
The contents of the file vcpkg\installed\status:
installed-status.txt
The text was updated successfully, but these errors were encountered: