https://bugs.winehq.org/show_bug.cgi?id=47812
Bug ID: 47812 Summary: Cygwin's strace.exe crashes due to custom TLS corruption Product: Wine Version: 4.16 Hardware: x86 OS: Linux Status: NEW Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: z.figura12@gmail.com Distribution: ---
This is not (as far as I can see) a Wine bug, and it's certainly not worth fixing, but I'm writing this down here so that someone doesn't go through the same work to figure it out...
Cygwin, for whatever reason, reimplements TLS by storing things at a fixed offset from the stack base (i.e. NtCurrentTeb()->Tib.StackBase). Somewhere along the line this gets corrupted, specifically the _locale member.
I think the assumptions made at [1] with regard to alloca() are just bogus. There's no guarantee that the returned memory will contain wholly the custom TLS slot, and I'm not particularly sure why they expect it to remain untouched after DLL_PROCESS_ATTACH returns.
[1] https://github.com/Alexpux/Cygwin/blob/master/winsup/cygwin/init.cc#L90
https://bugs.winehq.org/show_bug.cgi?id=47812
Zebediah Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |25b093f3845a0ae1b2e2fe1c070 | |1e98064f8e8d6 Component|-unknown |ntdll URL| |http://cygwin.com/setup-x86 | |_64.exe Resolution|--- |FIXED Status|NEW |RESOLVED Keywords| |download
--- Comment #1 from Zebediah Figura z.figura12@gmail.com --- Today, surprisingly enough, I believe this bug has been fixed. We now have a separate kernel stack, which means that while Cygwin is still doing something very fragile, we are no longer touching the stack between DLL attach and thread initialization, and as a result Cygwin's custom TLS does not get corrupted.
Unfortunately I didn't save the original Cygwin version or command I used to reproduce this, but I tested with the following and encountered no crashes, with strace version 3.2.0, echo 8.26, and Cygwin version 2.908.
wine strace.exe --output hello-strace -f echo.exe 'world hello' > hello.out
Fixed by https://source.winehq.org/git/wine.git/commitdiff/25b093f3845a0ae1b2e2fe1c0701e98064f8e8d6 for x86_64, and its parent for i386.
https://bugs.winehq.org/show_bug.cgi?id=47812
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #2 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 6.11.