Dlopen crash (receiving SIGBUS)

One of my applications is crashing due to the SIGBUS signal. Below is the stack trace from gdb. Basically, the dlopen call fails. I am running CentOS 6.3 64 bit.

Program received signal SIGBUS, Bus error.
0x0000003cfc6175de in strcpy () from /lib64/ld-linux-x86-64.so.2
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.el6_6.9.x86_64 libgcc-4.4.7-11.el6.x86_64 libstdc++-4.4.7-11.el6.x86_64
(gdb) bt
#0  0x0000003cfc6175de in strcpy () from /lib64/ld-linux-x86-64.so.2
#1  0x0000003cfc6090b2 in _dl_load_cache_lookup () from /lib64/ld-linux-x86-64.so.2
#2  0x0000003cfc608612 in _dl_map_object () from /lib64/ld-linux-x86-64.so.2
#3  0x0000003cfc612b05 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#4  0x0000003cfc60e266 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#5  0x0000003cfc6125aa in _dl_open () from /lib64/ld-linux-x86-64.so.2
#6  0x0000003cfca00f66 in dlopen_doit () from /lib64/libdl.so.2
#7  0x0000003cfc60e266 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#8  0x0000003cfca0129c in _dlerror_run () from /lib64/libdl.so.2
#9  0x0000003cfca00ee1 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
#10 0x00000000004b4425 in my_open_dbus_func (f_name=0x558f2d "libdbus-glib-1.so.2")

      

I tried writing a simple program with these two lines that works fine:

void * h = dlopen( "libdbus-glib-1.so.2", RTLD_LAZY );
dlclose( h );

      

I also tried running my original app under valgrind and it worked without issue.

Any hints / pointers are really appreciated.

+3


source to share


2 answers


It looks like one of the static libraries (from a third party bucket) was doing shadow memory management which was somehow causing my dlopen call to crash. The code was written to make sense of the virtual environment. The problem could have been easily discovered on valgrind, but if the app is running under valgrind, the third party library will use a different code path (given that valgrind is a physical machine)



unfortunately I don't know what they were fixing in their static library, but it seems to work. I am writing this answer (and accept it) to avoid any further confusion.

+1


source


Try to check if it's not h

NULL after dlopen

. I can imagine it dlclose

might fail with a NULL pointer given as a parameter.



0


source







All Articles