Skip to content

Commit 5508040

Browse files
committed
Correct stack base calculation on Mac and NuttX
VELAPLATFO-1343 Signed-off-by: Huang Qi <huangqi3@xiaomi.com> Change-Id: I3b69cd1c4819e494f16e32582c6764bcfb0075fe
1 parent ee97e30 commit 5508040

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/shared/platform/common/posix/posix_thread.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,10 @@ os_thread_get_stack_boundary()
327327
if ((addr = (uint8 *)pthread_get_stackaddr_np(self))) {
328328
stack_size = pthread_get_stacksize_np(self);
329329
if (stack_size > max_stack_size)
330-
addr -= max_stack_size;
331-
else
330+
stack_size = max_stack_size;
331+
332+
/* Check whether stack_addr is the base or end of the stack */
333+
if (addr > (uint8 *)&stack_size)
332334
addr -= stack_size;
333335
/* Reserved 1 guard page at least for safety */
334336
addr += page_size;

0 commit comments

Comments
 (0)