mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 15:05:19 +00:00
Correct stack base calculation on Mac and NuttX (#963)
The return address of pthread_get_stackaddr_np() in MacOS and NuttX may be the base address or the end (boundary) address of the native stack, if it is the end address, we get the base address according to it and the stack size, so as to get the actual stack boundary address correctly. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
parent
092efbfe21
commit
e0511fe822
|
@ -326,10 +326,18 @@ os_thread_get_stack_boundary()
|
|||
#elif defined(__APPLE__) || defined(__NuttX__)
|
||||
if ((addr = (uint8 *)pthread_get_stackaddr_np(self))) {
|
||||
stack_size = pthread_get_stacksize_np(self);
|
||||
|
||||
/**
|
||||
* Check whether stack_addr is the base or end of the stack,
|
||||
* change it to the base if it is the end of stack.
|
||||
*/
|
||||
if (addr <= (uint8 *)&stack_size)
|
||||
addr = addr + stack_size;
|
||||
|
||||
if (stack_size > max_stack_size)
|
||||
addr -= max_stack_size;
|
||||
else
|
||||
addr -= stack_size;
|
||||
stack_size = max_stack_size;
|
||||
|
||||
addr -= stack_size;
|
||||
/* Reserved 1 guard page at least for safety */
|
||||
addr += page_size;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user