Browse Source

libobs: Use RTLD_NOW to load modules

RTLD_LAZY means that symbols will only be resolved when first used,
while RTLD_NOW tries to resolve them immediately. This means that if
there are missing symbols (e.g, because a function got removed from
libobs), dlopen with RTLD_LAZY will happily open that module but we get
a runtime crash when the module tries to use that symbol, while with
RTLD_NOW we instead get a (nicer) error on dlopen.
Sebastian Beckmann 1 month ago
parent
commit
62429135ba
1 changed files with 3 additions and 3 deletions
  1. 3 3
      libobs/util/platform-nix.c

+ 3 - 3
libobs/util/platform-nix.c

@@ -82,7 +82,7 @@ void *os_dlopen(const char *path)
 		dstr_cat(&dylib_name, ".so");
 
 #ifdef __APPLE__
-	int dlopen_flags = RTLD_LAZY | RTLD_FIRST;
+	int dlopen_flags = RTLD_NOW | RTLD_FIRST;
 	if (dstr_find(&dylib_name, "Python")) {
 		dlopen_flags = dlopen_flags | RTLD_GLOBAL;
 	} else {
@@ -90,7 +90,7 @@ void *os_dlopen(const char *path)
 	}
 	void *res = dlopen(dylib_name.array, dlopen_flags);
 #else
-	void *res = dlopen(dylib_name.array, RTLD_LAZY);
+	void *res = dlopen(dylib_name.array, RTLD_NOW);
 #endif
 	if (!res)
 		blog(LOG_ERROR, "os_dlopen(%s->%s): %s\n", path, dylib_name.array, dlerror());
@@ -113,7 +113,7 @@ void os_dlclose(void *module)
 #if !defined(__APPLE__)
 int module_has_qt5_check(const char *path)
 {
-	void *mod = os_dlopen(path);
+	void *mod = dlopen(path, RTLD_LAZY);
 	if (mod == NULL) {
 		return 1;
 	}