From 6a8471f1f9e5e26d11d923e7cb690606cac8e049 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 20 Nov 2023 09:25:03 -0600 Subject: [PATCH] fixed: bug with wasmer runtime crashing on new thread creation --- runtime/src/ort_threads.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/src/ort_threads.h b/runtime/src/ort_threads.h index 92cc35a5..7dc470b3 100644 --- a/runtime/src/ort_threads.h +++ b/runtime/src/ort_threads.h @@ -31,10 +31,6 @@ static i32 onyx_run_thread(void *data) { #endif OnyxThread *thread = (OnyxThread *) data; - wasm_trap_t* traps = NULL; - thread->instance = runtime->wasm_instance_new(runtime->wasm_store, runtime->wasm_module, &runtime->wasm_imports, &traps); - assert(thread->instance); - wasm_extern_t* start_extern = runtime->wasm_extern_lookup_by_name(runtime->wasm_module, thread->instance, "_thread_start"); wasm_func_t* start_func = runtime->wasm_extern_as_func(start_extern); @@ -94,6 +90,10 @@ ONYX_DEF(__spawn_thread, (WASM_I32, WASM_I32, WASM_I32, WASM_I32, WASM_I32, WASM thread->closureptr = params->data[4].of.i32; thread->dataptr = params->data[6].of.i32; + wasm_trap_t* traps = NULL; + thread->instance = runtime->wasm_instance_new(runtime->wasm_store, runtime->wasm_module, &runtime->wasm_imports, &traps); + assert(thread->instance); + #if defined(_BH_LINUX) || defined(_BH_DARWIN) pthread_create(&thread->thread, NULL, onyx_run_thread, thread); #endif -- 2.25.1