From 1c65516164a015bf58ab1b513ad2d44783eea37b Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 10 Jul 2020 10:52:03 -0400 Subject: [PATCH] chore: log invalid module errors --- runtime/include/module.h | 14 +++++++++++++- runtime/include/panic.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/runtime/include/module.h b/runtime/include/module.h index 3a4d6b6..4544de1 100644 --- a/runtime/include/module.h +++ b/runtime/include/module.h @@ -132,7 +132,19 @@ module_initialize_memory(struct module *module) static inline bool module_is_valid(struct module *module) { - return (module && module->dynamic_library_handle && module->main); + if (!module) { + fprintf(stderr, "%lu | module %p | module is unexpectedly NULL\n", pthread_self(), module); + return false; + } else if (!module->dynamic_library_handle) { + fprintf(stderr, "%lu | module %p | module->dynamic_library_handle is unexpectedly NULL\n", + pthread_self(), module); + return false; + } else if (!module->main) { + fprintf(stderr, "%lu | module %p | module->main is unexpectedly NULL\n", pthread_self(), module); + return false; + } + + return true; } /** diff --git a/runtime/include/panic.h b/runtime/include/panic.h index d973c4b..4b28101 100644 --- a/runtime/include/panic.h +++ b/runtime/include/panic.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include