[PATCH] Cygwin: Fixing the math behind rounding down ch.stacklimit to page size
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue May 29 16:48:00 GMT 2018
Hi Sergejs,
On May 25 17:43, Sergejs Lukanihins wrote:
> Hello,
>
> 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.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20180529/ac2fa1a4/attachment.sig>
More information about the Cygwin-patches
mailing list