cerr crash in dlopen'ed c++ shared object, if linked to some libs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-4.4 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: gcc-4.4
I have main in c, which dlopens a c++ shared object. Upon calling a function (obtained with dlsym) in this c++ lib which uses cerr, there is segmentation fault. It happens only if the shared object links to some other libraries (like gomp or GL, even if unused). It doesn't happen if the main program is compiled with g++ however.
Here are sources (I will attach those as well) and below is backtrace from the debug version of libstdc++.
I am running fully updated karmic; the same problem occurs at an updated hardy and Debian lenny (I don't have access to other systems).
This is minimal testcase, I have this problem when importing c++ (boost::python) module into python.
=== main.c ===
#include<dlfcn.h>
int main(void){
void* handle=
void(*
foo();
return 0;
}
=== foo.cc ===
#include<iostream>
extern "C" {
void foo() { std::cerr<
}
=== regular run ===
$ g++ foo.cc -o libfoo.so -fPIC -rdynamic -shared
$ gcc main.c -o main -ldl
$ ./main
foo
=== link libfoo.so to another lib ===
$ g++ foo.cc -o libfoo.so -fPIC -rdynamic -shared -lgomp # might be GL, perhaps others as well
$ gcc main.c -o main -ldl
$ ./main
foozsh: segmentation fault (core dumped) ./main
=== compile main with g++, still link with gomp ===
$ g++ foo.cc -o libfoo.so -fPIC -rdynamic -shared -lgomp
$ g++ main.c -o main -ldl
$ ./main
foo
=== gdb bt from the crasher ===
$ g++ foo.cc -o libfoo.so -fPIC -rdynamic -shared -lgomp -g
$ gcc main.c -o main -ldl -g
$ LD_LIBRARY_
foozsh: segmentation fault (core dumped) LD_LIBRARY_
$ gdb main core
[ ... ]
(gdb) bt
#0 0x00007f81582c9e49 in std::uncaught_
#1 0x00007f8158294e04 in ~sentry (this=0x7fff3c4
#2 0x00007f8158295445 in std::__
at /build/
#3 0x00007f815829502e in std::operator<< <std::char_
at /build/
#4 0x00007f81590cf2e6 in foo () at foo.cc:3
#5 0x00000000004003a2 in main () at main.c:5
ProblemType: Bug
Architecture: amd64
Date: Tue Dec 1 09:56:47 2009
DistroRelease: Ubuntu 9.10
NonfreeKernelMo
Package: libstdc++6 4.4.1-4ubuntu8
ProcEnviron:
PATH=(custom, user)
LANG=cs_CZ.UTF-8
SHELL=/bin/zsh
ProcVersionSign
SourcePackage: gcc-4.4
Uname: Linux 2.6.31-16-generic x86_64
XsessionErrors:
(gnome-
(polkit-
(nautilus:2412): Eel-CRITICAL **: eel_preferences
(gnome-
this is a reasonable error due to the fact you haven't provided in the C++ shared object the necessary symbol Demangling. As well as your maybe calling the dlopen'd function incorrectly since dlsym returns a function pointer which you call as instead of a real function. http:// www.dwheeler. com/program- library/ Program- Library- HOWTO/dl- libraries. html
http:// publib. boulder. ibm.com/ infocenter/ comphelp/ v8v101/ index.jsp? topic=/ com.ibm. xlcpp8a. doc/proguide/ ref/rkcxxflt. htm
http:// developers. sun.com/ solaris/ articles/ mixing. html