If I try to use StabbyLibrary::get_stabbied on a function symbol named init_module, it returns something different compared to libloading and get_canaried.
To reproduce, rename the function called stable_fn to init_module in these two locations:
Recompile, and notice how the println! from the library is no longer executed.
The returned function pointer executes something, but it is no longer the expected library function, and returns -1 instead. If -1 is not a valid value for the return type of the function, then this causes a segmentation fault when trying to use it.
This doesn't seem to happen when using the standard libloading without get_stabbied, nor when using get_canaried instead of get_stabbied.
Renaming it to anything else makes the issue go away.
My guess is it loads init_module from libc.so.6 instead for some reason? Do the libloading/RTLD flags or loading methods differ between get_stabbied and get_canaried?
I tried rustc 1.73 and 1.77.1, downloaded through rustup, on a NixOS 23.11 system, with libloading = "0.8.3" and stabby = { version = "4.0.4", features = ["libloading"] }.
If I try to use
StabbyLibrary::get_stabbied
on a function symbol namedinit_module
, it returns something different compared tolibloading
andget_canaried
.To reproduce, rename the function called
stable_fn
toinit_module
in these two locations:https://github.com/ZettaScaleLabs/stabby/blob/fac3d32c7586b6064651b5c6ecf6bd2a22eff34f/examples/library/src/lib.rs#L16 https://github.com/ZettaScaleLabs/stabby/blob/fac3d32c7586b6064651b5c6ecf6bd2a22eff34f/examples/libloading/src/main.rs#L34
Recompile, and notice how the
println!
from the library is no longer executed.The returned function pointer executes something, but it is no longer the expected library function, and returns
-1
instead. If-1
is not a valid value for the return type of the function, then this causes a segmentation fault when trying to use it.This doesn't seem to happen when using the standard
libloading
withoutget_stabbied
, nor when usingget_canaried
instead ofget_stabbied
.Renaming it to anything else makes the issue go away.
My guess is it loads
init_module
fromlibc.so.6
instead for some reason? Do the libloading/RTLD flags or loading methods differ betweenget_stabbied
andget_canaried
?I tried rustc 1.73 and 1.77.1, downloaded through rustup, on a NixOS 23.11 system, with
libloading = "0.8.3"
andstabby = { version = "4.0.4", features = ["libloading"] }
.