-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
ccall(:foo) doesn't pick up LD_PRELOAD overrides #53747
Comments
While I haven't looked too deep into this, I imagine it has something to do with |
@staticfloat or anyone else, is there more insight on what's happening? At the very least I'd like to understand is it a bug/regression or is it by design? |
Bisected to 82c89c6 from #50162; cc @topolarity. |
So the reason this happens is that we lookup the symbols first in the libraries before we look them up in the main executable. That kind of behaves like RTLD_DEEPBIND, which has the side effect of making interposing symbols like this not work. The reason for that is to allow multiple julias to be loaded in the same process. I do wonder if we could try to restore the interposer behaviour a bit by looking non julia symbols in the executable and julia symbols in the library. |
It's worth mentioning that (as @gbaraldi points out), the new behavior is similar to the (pre-existing) behavior from the C side which is due to
I didn't think about |
This might break system profilers that use LD_PRELOAD? As an example in MPI.jl we use the pattern of We can of course change MPI to use the |
We already have a workaround for our case, but I can't see why inconsistent behaviour is acceptable. Also, I am worried there may be other unintended inconsistencies:
If all of that is not a concern, at the very least there should be a mention of those different behaviours in call documentation. |
I agree that this is important. The problem is that it's already inconsistent in 1.9: $ cat socket.c
#include "stdio.h"
__attribute__((visibility("default")))
int socket(int domain, int type, int protocol) {
fprintf(stderr, "Called LD_PRELOAD socket() hook\n");
return 42;
}
$ LD_PRELOAD=./socket.so julia-1.9 -e 'using Sockets; TCPSocket(; delay = false)'
Called LD_PRELOAD socket() hook
$ LD_PRELOAD=./socket.so julia-1.9 -e 'using MySQL; DBInterface.connect(MySQL.Connection, "localhost", "user", "passwd")'
<no hook message> Both of these use What's the deal? The difference here is that MySQL.jl is using In contrast, any of the "built-in" libraries (defined via |
We could check to see which library the symbol actually resolved to, and if it's not one of the |
Wouldn't it mean that different Julia processes potentially loading different versions of JLL's will step onto each other's toes? |
we're using a custom network stack library that loads via LD_PRELOAD mechanism and overrides certain function calls (
socket()
,recv()
,setsockopt()
and others). For some reason starting julia-1.10ccall(:socket)
doesn't pick up LD_PRELOAD version of the call anymore.We found a workaround to call
ccall((:socket, ""))
works with our LD_PRELOAD network stack. We'd like to understand what's changed and how the twoccall()
versions are different and how we can make sure we don't hit that in the future versions.Repro:
Julia downloaded from https://julialang-s3.julialang.org/bin/linux/x64/1.10/julia-1.10.2-linux-x86_64.tar.gz
The text was updated successfully, but these errors were encountered: