[PATCH] Cygwin: Fixing the math behind rounding down ch.stacklimit to page size
Tue May 29 16:48:00 GMT 2018
On May 25 17:43, Sergejs Lukanihins wrote:
> Looks like ch.stacklimit wasn't being page-aligned correctly in
> fork.cc; you need to subtract 1 from page_size to do it correctly (see
> the attached patch).
> As a result, this was causing stack-overflow exceptions whenever the
> stack needed to grow beyond the stacklimit value. When the stack grows
> beyond stacklimit value, Windows uses ntdll!_chkstk() function to
> check the stack and map in additional stack pages. However, it expects
> stacklimit to be page aligned, and the function does not work
> correctly if it is not (it triggers STATUS_STACK_OVERFLOW, even if
> there is enough stack space).
> Normally, this was not causing any issues, as the stack never really
> needs to grow, but it was causing issues when AV software was being
> injected into the process (specifically, HitmanPro.Alert being
> injected into git’s sh.exe process). Due to function hooks, it lead to
> a bigger callstack, and more stack space being required. Making the
> change specified in the patch actually resolves the issue.
> I am providing my patches to the Cygwin sources under the 2-clause BSD license.
Good catch! Patch pushed.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the Cygwin-patches