|
| 1 | +From aad54942583f8658ab6d7e7af5ffe3b76b3f35b3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Zoltan Varga <vargaz@gmail.com> |
| 3 | +Date: Tue, 3 Sep 2019 13:27:24 -0400 |
| 4 | +Subject: [PATCH] [wasm] Avoid aligning the stack bounds, they are not page |
| 5 | + aligned on wasm. |
| 6 | + |
| 7 | +--- |
| 8 | + mono/utils/mono-threads-wasm.c | 8 ++++---- |
| 9 | + mono/utils/mono-threads.c | 2 ++ |
| 10 | + 2 files changed, 6 insertions(+), 4 deletions(-) |
| 11 | + |
| 12 | +diff --git a/mono/utils/mono-threads-wasm.c b/mono/utils/mono-threads-wasm.c |
| 13 | +index 687e6c4c93e7..c61d800f4be2 100644 |
| 14 | +--- a/mono/utils/mono-threads-wasm.c |
| 15 | ++++ b/mono/utils/mono-threads-wasm.c |
| 16 | +@@ -145,10 +145,10 @@ mono_threads_platform_yield (void) |
| 17 | + void |
| 18 | + mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize) |
| 19 | + { |
| 20 | ++ int tmp; |
| 21 | + #ifdef __EMSCRIPTEN_PTHREADS__ |
| 22 | + pthread_attr_t attr; |
| 23 | + gint res; |
| 24 | +- int tmp; |
| 25 | + |
| 26 | + *staddr = NULL; |
| 27 | + *stsize = (size_t)-1; |
| 28 | +@@ -173,13 +173,13 @@ mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize) |
| 29 | + *staddr = (guint8*)wasm_get_stack_base (); |
| 30 | + *stsize = wasm_get_stack_size (); |
| 31 | + } |
| 32 | +- |
| 33 | +- g_assert (&tmp > *staddr); |
| 34 | +- g_assert (&tmp < (char*)*staddr + *stsize); |
| 35 | + #else |
| 36 | + *staddr = (guint8*)wasm_get_stack_base (); |
| 37 | + *stsize = wasm_get_stack_size (); |
| 38 | + #endif |
| 39 | ++ |
| 40 | ++ g_assert ((guint8*)&tmp > *staddr); |
| 41 | ++ g_assert ((guint8*)&tmp < (guint8*)*staddr + *stsize); |
| 42 | + } |
| 43 | + |
| 44 | + gboolean |
| 45 | +diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c |
| 46 | +index 546704ff9e8f..bf73e01c7970 100644 |
| 47 | +--- a/mono/utils/mono-threads.c |
| 48 | ++++ b/mono/utils/mono-threads.c |
| 49 | +@@ -1569,8 +1569,10 @@ mono_thread_info_get_stack_bounds (guint8 **staddr, size_t *stsize) |
| 50 | + /* Sanity check the result */ |
| 51 | + g_assert ((current > *staddr) && (current < *staddr + *stsize)); |
| 52 | + |
| 53 | ++#ifndef TARGET_WASM |
| 54 | + /* When running under emacs, sometimes staddr is not aligned to a page size */ |
| 55 | + *staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize () - 1)); |
| 56 | ++#endif |
| 57 | + } |
| 58 | + |
| 59 | + gboolean |
0 commit comments