-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use DEEPBIND
flag when loading external modules using dlopen
#1703
Conversation
The current flags used in `dlopen` to load external modules don't allow modules to define symbols that are already defined by the valkey server binary because the symbol resolution first looks in the server memory and only if it does not find anything, it looks in the module (shared library) memory. This might become a problem if, for instance, we try to implement a new scripting engine based on a newer version of Lua. The Lua interpreter library shares many symbol names with the Lua interpreter included in the Valkey server binary. To fix the above problem, this PR adds the flag `RTLD_DEEPBIND` to the flags used in `dlopen`, which changes the symbol resolution strategy to look for the symbol in the module memory first, if the code executing is from the module. Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1703 +/- ##
=========================================
Coverage 71.10% 71.11%
=========================================
Files 123 123
Lines 65523 65532 +9
=========================================
+ Hits 46590 46600 +10
+ Misses 18933 18932 -1
|
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
@rjd15372 Daily job failed: https://github.com/valkey-io/valkey/actions/runs/13253032412/job/36994775025 ==89691==You are trying to dlopen a /home/runner/work/valkey/valkey/tests/modules/reply.so shared library with RTLD_DEEPBIND flag which is incompatible with sanitizer runtime (see google/sanitizers#611 for details). If you want to run /home/runner/work/valkey/valkey/tests/modules/reply.so library under sanitizers please remove RTLD_DEEPBIND from dlopen flags. |
I see we did skip it, is there anything missing in the condition?
|
@enjoy-binbin see this: #1707 |
Fixes the failure trying to use dlopen with DEEPBIND with ASAN when compiling with Clang: ==90510==You are trying to dlopen a /home/runner/work/valkey/valkey/tests/modules/keyspecs.so shared library with RTLD_DEEPBIND flag which is incompatible with sanitizer runtime (see google/sanitizers#611 for details). If you want to run /home/runner/work/valkey/valkey/tests/modules/keyspecs.so library under sanitizers please remove RTLD_DEEPBIND from dlopen flags. https://github.com/valkey-io/valkey/actions/runs/13261241213/job/37018133361 The previous check only covers GCC. Additionally, don't require GLIBC when FreeBSD is used. FreeBSD has it's own libc which supports DEEPBIND according to its docs. Follow-up of #1703, #1707 Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
The current flags used in
dlopen
to load external modules don't allow modules to define symbols that are already defined by the valkey server binary because the symbol resolution first looks in the server memory and only if it does not find anything, it looks in the module (shared library) memory.This might become a problem if, for instance, we try to implement a new scripting engine based on a newer version of Lua. The Lua interpreter library shares many symbol names with the Lua interpreter included in the Valkey server binary.
To fix the above problem, this PR adds the flag
RTLD_DEEPBIND
to the flags used indlopen
on systems that support it, which changes the symbol resolution strategy to look for the symbol in the module memory first, if the code executing is from the module.