[Bug 48875] New: Segfault when calling InitializeCriticalSection (Kernel32.dll) during static initialization
https://bugs.winehq.org/show_bug.cgi?id=48875 Bug ID: 48875 Summary: Segfault when calling InitializeCriticalSection (Kernel32.dll) during static initialization Product: Wine Version: 5.5 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winelib Assignee: wine-bugs(a)winehq.org Reporter: winehq(a)twig.hk Distribution: --- Created attachment 66810 --> https://bugs.winehq.org/attachment.cgi?id=66810 Example Code that causes segfault When InitializeCriticalSection is called during static initialization, the program segfaults. When it's removed, or moved into WinMain, it does not. Code Snippet: #include <windows.h> CRITICAL_SECTION crit; struct Critical{ Critical(){ InitializeCriticalSection(&crit); } }; static Critical critical; ...Snip... The code was compiled and run with: wineg++ simple.cpp && wine a.out.so -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 --- Comment #1 from Thomas <winehq(a)twig.hk> --- Created attachment 66811 --> https://bugs.winehq.org/attachment.cgi?id=66811 Backtrace from wine-3.6 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 --- Comment #2 from Thomas <winehq(a)twig.hk> --- When using wine-3.6, i can get a backtrace from gdb: #0 0x00000000000043d4 in ?? () #1 0x00007ffff7ee198d in Critical::Critical (this=<optimized out>) at simple.cpp:9 #2 __static_initialization_and_destruction_0 (__initialize_p=__initialize_p(a)entry=1, __priority=__priority(a)entry=65535) at simple.cpp:13 ...Snip... -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 joaopa <jeremielapuree(a)yahoo.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jeremielapuree(a)yahoo.fr --- Comment #3 from joaopa <jeremielapuree(a)yahoo.fr> --- Can you try with wine-5.5? Wine-3.6 is very old. And can you a give the URL of a freely downloadable application showing the problem? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 --- Comment #4 from Thomas <winehq(a)twig.hk> --- (In reply to joaopa from comment #3)
Can you try with wine-5.5? Wine-3.6 is very old.
And can you a give the URL of a freely downloadable application showing the problem?
I tried with 5.5, but couldn't work out how to get a readable backtrace from it, it still crashes and the segfault memory address is still a bit too small. I have attached the source of the example program i have been using for testing? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 --- Comment #5 from Thomas <winehq(a)twig.hk> --- Backtrace from wine-5.5: Program received signal SIGSEGV, Segmentation fault. 0x0000000000013400 in ?? () (gdb) bt #0 0x0000000000013400 in ?? () #1 0x00007ffff7e4e55f in ?? () #2 0x0000000000000000 in ?? () -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 Thomas <winehq(a)twig.hk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #66810|0 |1 is obsolete| | --- Comment #6 from Thomas <winehq(a)twig.hk> --- Created attachment 66812 --> https://bugs.winehq.org/attachment.cgi?id=66812 Simpler code that still causes the segfault -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 --- Comment #7 from Nikolay Sivov <bunglehead(a)gmail.com> --- (In reply to Thomas from comment #6)
Created attachment 66812 [details] Simpler code that still causes the segfault
I tried this, built as: x86_64-w64-mingw32-gcc bug48875.cpp -o bug48875.exe and I don't see any crashes. Could you attach pre-built exe? Or build instructions. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 --- Comment #8 from Thomas <winehq(a)twig.hk> --- (In reply to Nikolay Sivov from comment #7)
(In reply to Thomas from comment #6)
Created attachment 66812 [details] Simpler code that still causes the segfault
I tried this, built as:
x86_64-w64-mingw32-gcc bug48875.cpp -o bug48875.exe
and I don't see any crashes. Could you attach pre-built exe? Or build instructions.
It's using wine lib, so to compile and run: wineg++ simple.cpp && wine a.out.so -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 Fabian Maurer <dark.shadow4(a)web.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dark.shadow4(a)web.de --- Comment #9 from Fabian Maurer <dark.shadow4(a)web.de> --- You don't even need the InitializeCriticalSection in WinMain. Confirming the crash, although I can't get a backtrace either. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 --- Comment #10 from Thomas <winehq(a)twig.hk> --- (In reply to Fabian Maurer from comment #9)
You don't even need the InitializeCriticalSection in WinMain. Confirming the crash, although I can't get a backtrace either.
That's true. It was there so you can show that it's not InitializeCriticalSection causing the crash. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 Fabian Maurer <dark.shadow4(a)web.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source Summary|Segfault when calling |Winelib applications can't |InitializeCriticalSection |call the Wine API during |(Kernel32.dll) during |static constructors |static initialization | Resolution|--- |DUPLICATE Status|UNCONFIRMED |RESOLVED --- Comment #11 from Fabian Maurer <dark.shadow4(a)web.de> --- Okay, so the problem is indeed the program being a .so file (winelib) instead of an .exe (MinGW). When the program is loaded, during wine_dlopen, the static constructors are run. But only during main, wine gets a chance to fixup the imports by calling LdrInitializeThunk. So during static constructors no wine code can be called, since the imports are not fixed up yet. No idea how to solve this though. Marking dupe of already existing bug 40502. *** This bug has been marked as a duplicate of bug 40502 *** -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=48875 Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #12 from Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> --- Closing Duplicate -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla