https://bugs.winehq.org/show_bug.cgi?id=47808
Bug ID: 47808 Summary: Cygwin's mintty.exe crashes with a stack overflow Product: Wine Version: 4.16 Hardware: x86-64 URL: https://cygwin.com/setup-x86_64.exe OS: Linux Status: NEW Keywords: download Severity: normal Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: z.figura12@gmail.com Distribution: ---
Created attachment 65297 --> https://bugs.winehq.org/attachment.cgi?id=65297 hack: always expand the stack if within the stack reserve
The problem is that Cygwin replaces the default stack with one that they've manually allocated, for whatever reason. Unlike Wine's stack, their stack is actually split into reserved and committed parts.
Then somewhere in gdi32, libfreetype jumps multiple pages of stack at once, skipping the guard page and triggering a stack overflow. It's within the reserved portion, but it never touches the guard pages, so we abort immediately. This is never a problem normally, because Wine commits the whole stack instead of just part of it.
The architecturally correct way to fix this is normally to have any such function use _chkstk(). But it's within libfreetype, so that isn't going to work. The attached patch fixes the bug, but it's probably not correct. I don't know how much better we can do, though...