feat: unreachable trap support

master
Sean McBride 3 years ago
parent 47b94ac9ad
commit ac374e72fd

@ -26,7 +26,7 @@ dist:
dist/%.o: src/%.c dist
clang ${CFLAGS} -c ${INCLUDES} -o $@ $<
dist/libsledge.a: dist/memory_instructions.o dist/numeric_instructions.o dist/table_instructions.o dist/variable_instructions.o dist/instantiation.o dist/wasi_snapshot_preview1.o
dist/libsledge.a: dist/control_instructions.o dist/memory_instructions.o dist/numeric_instructions.o dist/table_instructions.o dist/variable_instructions.o dist/instantiation.o dist/wasi_snapshot_preview1.o
ar rcs dist/libsledge.a $^
clean:

@ -51,6 +51,7 @@ enum sledge_abi__wasm_trap
WASM_TRAP_PROTECTED_CALL_STACK_OVERFLOW = 4,
WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY = 5,
WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION = 6,
WASM_TRAP_UNREACHABLE = 7,
WASM_TRAP_COUNT
};

@ -0,0 +1,7 @@
#include "sledge_abi.h"
void
awsm_abi__trap_unreachable(void)
{
sledge_abi__wasm_trap_raise(WASM_TRAP_UNREACHABLE);
}

@ -114,6 +114,16 @@ current_sandbox_wasm_trap_handler(int trapno)
client_socket_send(sandbox->client_socket_descriptor, http_header_build(500), http_header_len(500),
current_sandbox_sleep);
break;
case WASM_TRAP_UNREACHABLE:
error_message = "WebAssembly Trap: Unreachable Instruction\n";
client_socket_send(sandbox->client_socket_descriptor, http_header_build(500), http_header_len(500),
current_sandbox_sleep);
break;
default:
error_message = "WebAssembly Trap: Unknown Trapno\n";
client_socket_send(sandbox->client_socket_descriptor, http_header_build(500), http_header_len(500),
current_sandbox_sleep);
break;
}
debuglog("%s", error_message);

Loading…
Cancel
Save