From e3261244eecd8fca0362bc09964f4a5b8a741ba5 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Tue, 11 Aug 2020 20:13:04 -0400 Subject: [PATCH] chore: replace aborts with panics --- runtime/include/sandbox.h | 2 +- runtime/src/arch_context.c | 4 +++- runtime/src/libc/uvio.c | 2 +- runtime/src/worker_thread.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/runtime/include/sandbox.h b/runtime/include/sandbox.h index 94f3aea..f97e968 100644 --- a/runtime/include/sandbox.h +++ b/runtime/include/sandbox.h @@ -181,7 +181,7 @@ sandbox_state_stringify(sandbox_state_t state) return "Error"; default: /* Crash, as this should be exclusive */ - abort(); + panic("%d is an unrecognized sandbox state\n", state); } } diff --git a/runtime/src/arch_context.c b/runtime/src/arch_context.c index cbd763a..c20ff12 100644 --- a/runtime/src/arch_context.c +++ b/runtime/src/arch_context.c @@ -3,6 +3,8 @@ #include #include +#include "panic.h" + /** * Called by the inline assembly in arch_context_switch to send a SIGUSR1 in order to restore a previously preempted * thread. The only way to restore all of the mcontext registers of a preempted sandbox is to send ourselves a signal, @@ -12,5 +14,5 @@ void __attribute__((noinline)) __attribute__((noreturn)) arch_context_restore_preempted(void) { pthread_kill(pthread_self(), SIGUSR1); - abort(); + panic("Unexpectedly reached code after sending self SIGUSR1\n"); } diff --git a/runtime/src/libc/uvio.c b/runtime/src/libc/uvio.c index d3ce0f5..5fdb836 100644 --- a/runtime/src/libc/uvio.c +++ b/runtime/src/libc/uvio.c @@ -628,7 +628,7 @@ wasm_fcntl(uint32_t file_descriptor, uint32_t cmd, uint32_t arg_or_lock_ptr) case WF_SETLK: return 0; default: - abort(); + panic("Invalid command %d\n", cmd); } } diff --git a/runtime/src/worker_thread.c b/runtime/src/worker_thread.c index 844cb50..7efd1f7 100644 --- a/runtime/src/worker_thread.c +++ b/runtime/src/worker_thread.c @@ -320,5 +320,5 @@ worker_thread_on_sandbox_exit(struct sandbox *exiting_sandbox) assert(!software_interrupt_is_enabled()); worker_thread_dump_lock_overhead(); worker_thread_switch_to_base_context(); - abort(); + panic("Unexpected return\n"); }