From 7cf457286d045870dd46a0d23317a3be884abb5a Mon Sep 17 00:00:00 2001 From: Philipp Schmutz <2059887+pschmutz@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:22:47 +0200 Subject: [PATCH] Print error instead of failing silently when loading plugins Previously the return value of dlopen was ignored, meaning a failed load of a shared library would stay unnoticed --- src/engine/engine_plugin.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/engine/engine_plugin.cc b/src/engine/engine_plugin.cc index 93ea4233..20a64bf1 100644 --- a/src/engine/engine_plugin.cc +++ b/src/engine/engine_plugin.cc @@ -387,7 +387,15 @@ void mj_loadPluginLibrary(const char* path) { #if defined(_WIN32) || defined(__CYGWIN__) LoadLibraryA(path); #else - dlopen(path, RTLD_NOW | RTLD_LOCAL); + void* handle = dlopen(path, RTLD_NOW | RTLD_LOCAL); + if (!handle) { + const char* error = dlerror(); + if (error) { + mju_error("Error loading plugin library '%s': %s\n", path, error); + } else { + mju_error("Unknown error loading plugin library '%s'\n", path); + } + } #endif }