Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Crash in dlclose() of C++ shared object: (3 Items)
   
Crash in dlclose() of C++ shared object  
While testing our product under QNX 6.5.0 SP1, we encountered a crash that had not occurred in older versions of QNX. It
 occurs when calling dlclose() of a C++ shared library (DLL). The backtrace looks like this:

(gdb) bt
#0  0xb82b3329 in __gnu_cxx::__exchange_and_add (__mem=0x0, __val=-1)
    at atomicity.cc:36
#1  0xb8258471 in ~locale (this=0xb838d7fc)
    at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntox86/i486-pc-nto-qnx6.
5.0/pic/libstdc++-v3/include/ext/atomicity.h:79
#2  0xb8264aa9 in ~basic_filebuf (this=0xb838d7e0)
    at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntox86/i486-pc-nto-qnx6.
5.0/pic/libstdc++-v3/include/streambuf:193
#3  0xb032b734 in __cxa_finalize ()
   from /usr/qnx650/target/qnx6/x86/lib/libc.so.3
#4  0xb833fdd7 in ?? ()
#5  0xb8388200 in ?? ()
#6  0x00000000 in ?? ()

A reproducer program written in C and linked to libstdc++ calls dlopen() of a C++ library, looks up two symbols for 
functions, invokes them, and then calls dlclose(), at which point the crash occurs. If the C program is linked without -
lstdc++, it works fine. Before you say "then don't link with libstdc++" please note that our product requires the 
libstdc++ library. 

I have attached the reproducer test. Has anyone seen this crash before? I found a mention of a dlclose() crash in the 
release notes for 6.5.0 SP1 (Ref# 77236) that was fixed for ARMLE-v7, but we are using x86 and SP1 is supposed to have 
this fix anyway.

Randy Rorden
Atego

Attachment: Compressed file cxxdll.zip 1.7 KB
Re: Crash in dlclose() of C++ shared object  
You can not mix libcpp and libstdc++.

To correctly build your binary and shared object, pass -Y_gpp to qcc.

See docs here: http://www.qnx.com/developers/docs/6.5.0/index.jsp and 
search for "QCC".


HTH,

Aleksandar

Re: Crash in dlclose() of C++ shared object  
This has resolved the problem. Thanks!