From c4319d2c8e44aa8e10a1366bd3fe3d59e138f0a6 Mon Sep 17 00:00:00 2001 From: Aaron Miller Date: Tue, 13 Jun 2023 11:52:11 -0700 Subject: [PATCH] dlhandle: prevent libs from using each other's symbols (#977) use RTLD_LOCAL so that symbols are *only* exposed via dlsym without this all symbols exported by the libs are available for symbol resolution, resulting in different lib versions potentially resolving *each other's* symbols, causing incredibly cursed behavior such as https://gist.github.com/apage43/085c1ff69f6dd05387793ebc301840f6 --- gpt4all-backend/dlhandle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpt4all-backend/dlhandle.h b/gpt4all-backend/dlhandle.h index 0fae068f..c9e3f70e 100644 --- a/gpt4all-backend/dlhandle.h +++ b/gpt4all-backend/dlhandle.h @@ -18,7 +18,7 @@ public: }; Dlhandle() : chandle(nullptr) {} - Dlhandle(const std::string& fpath, int flags = RTLD_LAZY) { + Dlhandle(const std::string& fpath, int flags = RTLD_LAZY | RTLD_LOCAL) { chandle = dlopen(fpath.c_str(), flags); if (!chandle) { throw Exception("dlopen(\""+fpath+"\"): "+dlerror());