diff options
author | 刘皓 <[email protected]> | 2025-03-27 00:34:27 -0400 |
---|---|---|
committer | Yuta Saito <[email protected]> | 2025-03-31 11:59:33 +0900 |
commit | 72fc9c7b1580251eac7d8db116df7f6e436be8b3 () | |
tree | 844d90c5ef102c81aed0b8b6bc392de640b7d452 | |
parent | dea505dea014c45062fb2963d4eb770be1497a4a (diff) |
Fix stack pointer corruption in setjmp handler in WASI builds
Notes: Merged: https://.com/ruby/ruby/pull/12995
-rw-r--r-- | wasm/setjmp.c | 8 | ||||
-rw-r--r-- | wasm/setjmp.h | 1 |
2 files changed, 9 insertions, 0 deletions
@@ -143,9 +143,11 @@ rb_wasm_try_catch_init(struct rb_wasm_try_catch *try_catch, try_catch->try_f = try_f; try_catch->catch_f = catch_f; try_catch->context = context; } // NOTE: This function is not processed by Asyncify due to a call of asyncify_stop_rewind void rb_wasm_try_catch_loop_run(struct rb_wasm_try_catch *try_catch, rb_wasm_jmp_buf *target) { @@ -154,6 +156,10 @@ rb_wasm_try_catch_loop_run(struct rb_wasm_try_catch *try_catch, rb_wasm_jmp_buf target->state = JMP_BUF_STATE_CAPTURED; switch ((enum try_catch_phase)try_catch->state) { case TRY_CATCH_PHASE_MAIN: // may unwind @@ -175,6 +181,8 @@ rb_wasm_try_catch_loop_run(struct rb_wasm_try_catch *try_catch, rb_wasm_jmp_buf // stop unwinding // (but call stop_rewind to update the asyncify state to "normal" from "unwind") asyncify_stop_rewind(); // clear the active jmpbuf because it's already stopped _rb_wasm_active_jmpbuf = NULL; // reset jmpbuf state to be able to unwind again @@ -65,6 +65,7 @@ struct rb_wasm_try_catch { rb_wasm_try_catch_func_t try_f; rb_wasm_try_catch_func_t catch_f; void *context; int state; }; |