diff options
author | Yuta Saito <kateinoigakukun@gmail.com> | 2022-11-05 16:10:35 +0000 |
---|---|---|
committer | Yuta Saito <kateinoigakukun@gmail.com> | 2022-11-06 05:03:21 +0900 |
commit | 3a6cdeda89280ade714f158830acee88fb36306d (patch) | |
tree | 91a912f319883c125f60b2c9d25f0c76c52dc2d7 /thread_none.c | |
parent | 267452e6fed5d31dcad3c20970f74eec009dc03f (diff) | |
download | ruby-3a6cdeda89280ade714f158830acee88fb36306d.tar.gz |
[wasm] Scan machine stack based on `ec->machine.stack_{start,end}`
fiber machine stack is placed outside of C stack allocated by wasm-ld,
so highest stack address recorded by `rb_wasm_record_stack_base` is
invalid when running on non-main fiber.
Therefore, we should scan `stack_{start,end}` which always point a valid
stack range in any context.
Diffstat (limited to 'thread_none.c')
-rw-r--r-- | thread_none.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/thread_none.c b/thread_none.c index cf4658e571..a82ced684e 100644 --- a/thread_none.c +++ b/thread_none.c @@ -15,6 +15,10 @@ #include <time.h> +#if defined(__wasm__) && !defined(__EMSCRIPTEN__) +# include "wasm/machine.h" +#endif + #define TIME_QUANTUM_MSEC (100) #define TIME_QUANTUM_USEC (TIME_QUANTUM_MSEC * 1000) #define TIME_QUANTUM_NSEC (TIME_QUANTUM_USEC * 1000) @@ -143,6 +147,9 @@ ruby_init_stack(volatile VALUE *addr) static int native_thread_init_stack(rb_thread_t *th) { +#if defined(__wasm__) && !defined(__EMSCRIPTEN__) + th->ec->machine.stack_start = (VALUE *)rb_wasm_stack_get_base(); +#endif return 0; // success } |