diff --git a/src/ocre/components/container_supervisor/cs_sm_impl.c b/src/ocre/components/container_supervisor/cs_sm_impl.c index e7bc3312..229cb33a 100644 --- a/src/ocre/components/container_supervisor/cs_sm_impl.c +++ b/src/ocre/components/container_supervisor/cs_sm_impl.c @@ -131,8 +131,23 @@ static void container_thread_entry(void *args) { // Set TLS for the container's WASM module current_module_tls = &module_inst; #endif - // Run the WASM main function - bool success = wasm_application_execute_main(module_inst, 0, NULL); + + // Run the WASM main function with exception handling + bool success = false; + const char *exception = NULL; + + // Clear any previous exceptions + wasm_runtime_clear_exception(module_inst); + + // Execute main function + success = wasm_application_execute_main(module_inst, 0, NULL); + + // Check for exceptions + exception = wasm_runtime_get_exception(module_inst); + if (exception) { + LOG_ERR("Container %d exception: %s", container->container_ID, exception); + success = false; + } // Update container status if (container->container_runtime_status != CONTAINER_STATUS_STOPPED) container->container_runtime_status = success ? CONTAINER_STATUS_STOPPED : CONTAINER_STATUS_ERROR; @@ -161,7 +176,12 @@ static void container_thread_entry(void *args) { } core_mutex_unlock(&container->lock); - LOG_INF("Container thread %d exited cleanly", container->container_ID); + if (success) { + LOG_INF("Container %d completed successfully", container->container_ID); + } else { + LOG_ERR("Container %d failed: %s", container->container_ID, + exception ? exception : "unknown error"); + } // Clean up WASM runtime thread environment wasm_runtime_destroy_thread_env(); diff --git a/src/ocre/ocre_gpio/ocre_gpio.c b/src/ocre/ocre_gpio/ocre_gpio.c index e99351e2..7a32de9c 100644 --- a/src/ocre/ocre_gpio/ocre_gpio.c +++ b/src/ocre/ocre_gpio/ocre_gpio.c @@ -267,7 +267,7 @@ int ocre_gpio_unregister_callback(int pin) { void ocre_gpio_cleanup_container(wasm_module_inst_t module_inst) { if (!gpio_system_initialized || !module_inst) { - LOG_ERR("GPIO system not initialized or invalid module %p", (void *)module_inst); + LOG_DBG("GPIO system not initialized or invalid module %p", (void *)module_inst); return; } for (int i = 0; i < CONFIG_OCRE_GPIO_MAX_PINS; i++) { diff --git a/wasm-micro-runtime b/wasm-micro-runtime index c9cf93fb..60253bed 160000 --- a/wasm-micro-runtime +++ b/wasm-micro-runtime @@ -1 +1 @@ -Subproject commit c9cf93fb10fe31e229658937a9afa2fbb41fb009 +Subproject commit 60253bedbbbc16ff586381f3cd142f639ce23d94