Bug #11438
closednative_thread_init_stack() get machine.stack_start unequal to thread's stack start address, x86 win32
Description
In function native_thread_init_stack() use VirtualQuery to get thread's stack start address.But some situation(ruby embbed in other application and initial it on the fly),native_thread_init_stack() will be called at low stack address and VirtualQuery return memory info BaseAddress + RegionSize < thread stack base(teb.StackBase).
In this situation,subsequently call stack_check() at high stack address will cause stack_overflow exception,because esp > machine.stack_start:
(teb.StackLimit < machine.stack_start < esp < teb.StackBase)
but actually it is not stack overflow at this time.
Use teb.StackBase instead of VirtualQuery get thread stack base is a more reliable solution.
Updated by hsbt (Hiroshi SHIBATA) over 2 years ago
- Status changed from Open to Assigned
Updated by hsbt (Hiroshi SHIBATA) 19 days ago
Updated by hsbt (Hiroshi SHIBATA) 16 days ago
- Status changed from Assigned to Closed
Applied in changeset git|e585c9449965a6837374e0c5436cf4be731802df.
win32: Use GetCurrentThreadStackLimits to set machine stack bounds
[Bug #11438]
VirtualQuery against a local variable address may return a region that
does not span the whole thread stack when the interpreter is
initialized deep in the stack, such as Ruby embedded in another
application. stack_check() then misfires with a bogus SystemStackError.
Updated by hsbt (Hiroshi SHIBATA) 16 days ago
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 3.3: WONTFIX, 3.4: REQUIRED, 4.0: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) 3 days ago
- Backport changed from 3.3: WONTFIX, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: WONTFIX, 3.4: DONE, 4.0: REQUIRED
ruby_3_4 44145cf4dc64fa4cebbec10d2ec3454fbfd65559 merged revision(s) e585c9449965a6837374e0c5436cf4be731802df.