[KERNEL32][RTL] Diverse fixes/improvements for thread stack creation code. (#802) 802/head
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 26 May 2016 02:44:25 +0000 (04:44 +0200)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 1 Aug 2019 17:04:13 +0000 (19:04 +0200)
commiteffdb6f232aa4448179c2b0a0f70aaa20856357c
tree34f121329c2c77b7de87d2c745e2f7fa784d84b1
parent4895f21efa522348742c28d6795c7d2768c74a8a
[KERNEL32][RTL] Diverse fixes/improvements for thread stack creation code. (#802)

- kernel32!BaseCreateStack() is compatible with ntdll!RtlpCreateUserStack().
- When checking whether a stack guard page can be added, its size has to
  be accounted for in the checking logic.
- We have to satisfy the PEB::MinimumStackCommit constraint.
- We cannot use PEB::GuaranteedStackBytes in BaseCreateStack() since it is
  nowhere initialized (default is 0). It gets initialized to a non-zero
  value when the user manually calls SetThreadStackGuarantee().
  https://www.installsetupconfig.com/win32programming/windowsthreadsprocessapis7_6.html

- RtlpCreateUserStack(): Fix memory leak in failure case.
- RtlpFreeUserStack() doesn't need to return anything.

See also commit 1bc59379 (r59868).

CORE-11319
dll/win32/kernel32/client/thread.c
dll/win32/kernel32/client/utils.c
dll/win32/kernel32/include/kernel32.h
sdk/lib/rtl/thread.c