I am bringing this question to internals group in the hope of getting a few more eyes on the problem for insights.
There is a existing LD_PRELOAD program that is used by our team libcpio_preload.so
I am writing attempting to write a new LD_PRELOAD program libwisktrack.so.
The basic "Hello world" version, which just simply eprintln!("Hello World");
segfaults. But only if the libwisktrack.so comes after libcpio_preload.so
The following segfaults
LD_PRELOAD=“/nobackup/sarvi/iosxr/platforms/common/thinxr/build/obj-x86-linux/libcpio_preload.so:/ws/sarvi-sjc/wisktrack/\${LIB}/libwisktrack.so” <anyhello world program>
The following does not segfault. The difference is the order of the libwisktrack.so and libcpio_preload.so
LD_PRELOAD=“/ws/sarvi-sjc/wisktrack/\${LIB}/libwisktrack.so:/nobackup/sarvi/iosxr/platforms/common/thinxr/build/obj-x86-linux/libcpio_preload.so” <anyhello world program>
libwisktrack.so has been stripped down to the following code. There is nothing else in the code.
#[link_section = ".init_array"]
pub static INITIALIZE: extern "C" fn() = crate::rust_ctor;
#[no_mangle]
pub extern "C" fn rust_ctor() {
eprintln!("Hello World");
}
If the eprintln!() was replaced by simple global static initialization, the segfault does not happen. Generates no useable backtrace, and doesnt print anything, even the "Hello World"
If I did the same basic version of libwisktrack.so in "C", no segfaults.
Question:
- any insights on how to debug this or what the cause might be
- I am suspecting something about what RUST standardly compiles into this library libwisktack.so, or something about RUST seems to be causing this problem as the C version doesnt crash. Any ideas on that path. How can I move forward.
PS: there is a thread in the RUST lang forum on this same subject