From 44370ebc3ed9e691baa0699dd3eb45bf90e43d86 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 7 Nov 2022 13:18:09 -0800 Subject: [PATCH] wasm2c: Uninstall sighandler in os_cleanup_signal_handler (#2043) --- wasm2c/wasm-rt-impl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wasm2c/wasm-rt-impl.c b/wasm2c/wasm-rt-impl.c index 4e81c7e75..7187b2838 100644 --- a/wasm2c/wasm-rt-impl.c +++ b/wasm2c/wasm-rt-impl.c @@ -296,6 +296,19 @@ static void os_install_signal_handler(void) { } static void os_cleanup_signal_handler(void) { + /* Undo what was done in os_install_signal_handler */ + struct sigaction sa; + sa.sa_handler = SIG_DFL; + if (sigaction(SIGSEGV, &sa, NULL) != 0 || sigaction(SIGBUS, &sa, NULL)) { + perror("sigaction failed"); + abort(); + } + + if (sigaltstack(NULL, NULL) != 0) { + perror("sigaltstack failed"); + abort(); + } + free(g_alt_stack); } #endif