Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-3364

Segmentation fault when unloading shared libraries linked with libqpidmessaging

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Cannot Reproduce
    • 0.8, 0.10, 0.11, 0.14
    • None
    • C++ Client
    • None

    Description

      Disclaimer: I'm not a dlopen/dlclose expert... I'm perfectly happy to be told that I don't know what I'm doing!

      Basic Description

      If I create a shared object (that may or may not implement anything) that links with libqpidmessaging (ie g++ ... -lqpidmessaging), and then create an application that dlopen's that library, then dlclose's that library, then that application will cause a seg-fault, which appears to be in the libqpidmessaging library itself.

      To demonstrate, I have a loadee.cpp file that contains just the following unimportant code:

      loadee.cpp
      void foo() { }
      

      Then I build a loadee.so shared object like:

      g++ -g -shared -lqpidmessaging -o loadee.so loadee.cpp
      

      Next I have:

      loader.cpp
      #include <stdio.h>
      #include <stdlib.h>
      #include <dlfcn.h>
      
      int main(int c, char *argv[]) {
          void *handle = dlopen("./loadee.so", RTLD_LAZY); // segfaults in dlclose below.
          //void *handle = dlopen("./loadee.so", RTLD_NOW); // no segfault.
          if (!handle) {
              fprintf(stderr, "%s\n", dlerror());
              exit(EXIT_FAILURE);
          }
          dlclose(handle);
          return EXIT_SUCCESS;
      }
      

      Finally I build the loader program like:

      g++ -g -rdynamic -o loader loader.cpp -ldl
      

      Now, if I run the resulting loader program, then the program seg-faults in libqpidmessaging. However, there is no such seg-fault (for me at least), if I either remove the -lqpidmessaging flag from the first g++ command, or change the flopen flags from RTLD_NOW to RTLD_LAZY (as indicated in the code comments above).

      Tested Versions

      I've tried this against the 0.8 and 0.10 tags, as well as trunk at r1148263, with both Autotools and CMake.

      GDB

      Unfortunately, gdb is not giving me much... very strange.

      paul@debian:~/src/simple$ gdb ./loader
      GNU gdb (GDB) 7.0.1-debian
      Copyright (C) 2009 Free Software Foundation, Inc.
      License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
      and "show warranty" for details.
      This GDB was configured as "i486-linux-gnu".
      For bug reporting instructions, please see:
      <http://www.gnu.org/software/gdb/bugs/>...
      Reading symbols from /home/paul/src/simple/loader...done.
      (gdb) run
      Starting program: /home/paul/src/simple/loader
      [Thread debugging using libthread_db enabled]
      Cannot find new threads: generic error
      (gdb) bt
      Target is executing.
      (gdb) bt full
      Target is executing.
      (gdb) thread apply all bt
      Cannot find new threads: generic error
      (gdb)
      

      Valgrind

      Valgrind is a little more interesting though...

      paul@debian:~/src/simple$ valgrind --leak-check=full --show-reachable=yes ./loader
      ==31992== Memcheck, a memory error detector
      ==31992== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
      ==31992== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
      ==31992== Command: ./loader
      ==31992==
      ==31992== Jump to the invalid address stated on the next line
      ==31992==    at 0x0: ???
      ==31992==    by 0x41A1687: __cxa_finalize (cxa_finalize.c:56)
      ==31992==    by 0x46ED0F3: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x473091F: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x401271D: _dl_close_worker (dl-close.c:271)
      ==31992==    by 0x4013196: _dl_close (dl-close.c:742)
      ==31992==    by 0x4034CA3: dlclose_doit (dlclose.c:37)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034CD9: dlclose (dlclose.c:48)
      ==31992==    by 0x8048812: main (loader.cpp:12)
      ==31992==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
      ==31992==
      ==31992==
      ==31992== Process terminating with default action of signal 11 (SIGSEGV)
      ==31992==  Bad permissions for mapped region at address 0x0
      ==31992==    at 0x0: ???
      ==31992==    by 0x41A1687: __cxa_finalize (cxa_finalize.c:56)
      ==31992==    by 0x46ED0F3: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x473091F: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x401271D: _dl_close_worker (dl-close.c:271)
      ==31992==    by 0x4013196: _dl_close (dl-close.c:742)
      ==31992==    by 0x4034CA3: dlclose_doit (dlclose.c:37)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034CD9: dlclose (dlclose.c:48)
      ==31992==    by 0x8048812: main (loader.cpp:12)
      ==31992==
      ==31992== HEAP SUMMARY:
      ==31992==     in use at exit: 17,489 bytes in 85 blocks
      ==31992==   total heap usage: 1,236 allocs, 1,151 frees, 54,608 bytes allocated
      ==31992==
      ==31992== 12 bytes in 1 blocks are still reachable in loss record 1 of 33
      ==31992==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
      ==31992==    by 0x400486E: local_strdup (dl-load.c:162)
      ==31992==    by 0x4007080: _dl_map_object (dl-load.c:2175)
      ==31992==    by 0x4011B25: dl_open_worker (dl-open.c:225)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034B40: dlopen@@GLIBC_2.1 (dlopen.c:88)
      ==31992==    by 0x80487D0: main (loader.cpp:6)
      ==31992==
      ==31992== 17 bytes in 1 blocks are possibly lost in loss record 2 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x480DBAC: global constructors keyed to Variant.cpp (Variant.cpp:174)
      ==31992==    by 0x481A7CC: ??? (in /usr/local/lib/libqpidtypes.so.1.0.0)
      ==31992==    by 0x480ACEF: ??? (in /usr/local/lib/libqpidtypes.so.1.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 18 bytes in 1 blocks are possibly lost in loss record 3 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x480DBE1: global constructors keyed to Variant.cpp (Variant.cpp:175)
      ==31992==    by 0x481A7CC: ??? (in /usr/local/lib/libqpidtypes.so.1.0.0)
      ==31992==    by 0x480ACEF: ??? (in /usr/local/lib/libqpidtypes.so.1.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 25 bytes in 1 blocks are possibly lost in loss record 4 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x471B2CC: global constructors keyed to OutgoingMessage.cpp (OutgoingMessage.cpp:44)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 25 bytes in 1 blocks are possibly lost in loss record 5 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x4716A4D: global constructors keyed to IncomingMessages.cpp (IncomingMessages.cpp:299)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 31 bytes in 1 blocks are possibly lost in loss record 6 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x471B301: global constructors keyed to OutgoingMessage.cpp (OutgoingMessage.cpp:45)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 31 bytes in 1 blocks are possibly lost in loss record 7 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x4716A82: global constructors keyed to IncomingMessages.cpp (IncomingMessages.cpp:301)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 33 bytes in 1 blocks are possibly lost in loss record 8 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x480DB77: global constructors keyed to Variant.cpp (Variant.cpp:36)
      ==31992==    by 0x481A7CC: ??? (in /usr/local/lib/libqpidtypes.so.1.0.0)
      ==31992==    by 0x480ACEF: ??? (in /usr/local/lib/libqpidtypes.so.1.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 36 bytes in 1 blocks are possibly lost in loss record 9 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x471B336: global constructors keyed to OutgoingMessage.cpp (OutgoingMessage.cpp:46)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 36 bytes in 1 blocks are possibly lost in loss record 10 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x4716AB7: global constructors keyed to IncomingMessages.cpp (IncomingMessages.cpp:302)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 41 bytes in 1 blocks are possibly lost in loss record 11 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x471B36B: global constructors keyed to OutgoingMessage.cpp (OutgoingMessage.cpp:47)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 41 bytes in 1 blocks are possibly lost in loss record 12 of 33
      ==31992==    at 0x402471C: operator new(unsigned int) (vg_replace_malloc.c:255)
      ==31992==    by 0x40D0795: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1493: ??? (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x40D1685: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
      ==31992==    by 0x4716AEC: global constructors keyed to IncomingMessages.cpp (IncomingMessages.cpp:303)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 140 bytes in 1 blocks are still reachable in loss record 13 of 33
      ==31992==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
      ==31992==    by 0x4023FDA: realloc (vg_replace_malloc.c:525)
      ==31992==    by 0x400A029: _dl_new_object (dl-object.c:169)
      ==31992==    by 0x40059B7: _dl_map_object_from_fd (dl-load.c:969)
      ==31992==    by 0x4007133: _dl_map_object (dl-load.c:2240)
      ==31992==    by 0x4011B25: dl_open_worker (dl-open.c:225)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034B40: dlopen@@GLIBC_2.1 (dlopen.c:88)
      ==31992==
      ==31992== 140 bytes in 1 blocks are still reachable in loss record 14 of 33
      ==31992==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
      ==31992==    by 0x400C37E: _dl_map_object_deps (dl-deps.c:506)
      ==31992==    by 0x4011B80: dl_open_worker (dl-open.c:262)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034B40: dlopen@@GLIBC_2.1 (dlopen.c:88)
      ==31992==    by 0x80487D0: main (loader.cpp:6)
      ==31992==
      ==31992== 308 bytes in 7 blocks are still reachable in loss record 15 of 33
      ==31992==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
      ==31992==    by 0x4009D51: _dl_lookup_symbol_x (dl-lookup.c:616)
      ==31992==    by 0x400A845: _dl_relocate_object (dl-machine.h:344)
      ==31992==    by 0x4011C55: dl_open_worker (dl-open.c:338)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034B40: dlopen@@GLIBC_2.1 (dlopen.c:88)
      ==31992==    by 0x80487D0: main (loader.cpp:6)
      ==31992==
      ==31992== 331 bytes in 10 blocks are still reachable in loss record 16 of 33
      ==31992==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
      ==31992==    by 0x400486E: local_strdup (dl-load.c:162)
      ==31992==    by 0x40073EC: _dl_map_object (dl-load.c:2148)
      ==31992==    by 0x400CE9B: openaux (dl-deps.c:65)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x400C191: _dl_map_object_deps (dl-deps.c:247)
      ==31992==    by 0x4011B80: dl_open_worker (dl-open.c:262)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==
      ==31992== 331 bytes in 10 blocks are still reachable in loss record 17 of 33
      ==31992==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
      ==31992==    by 0x400A113: _dl_new_object (dl-object.c:150)
      ==31992==    by 0x40059B7: _dl_map_object_from_fd (dl-load.c:969)
      ==31992==    by 0x4007133: _dl_map_object (dl-load.c:2240)
      ==31992==    by 0x400CE9B: openaux (dl-deps.c:65)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x400C191: _dl_map_object_deps (dl-deps.c:247)
      ==31992==    by 0x4011B80: dl_open_worker (dl-open.c:262)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 18 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x49ED792: global constructors keyed to DispatchHandle.cpp (iostream:72)
      ==31992==    by 0x49FF49C: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x48F7C1B: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 19 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x4972CA0: global constructors keyed to QueueQueryBody.cpp (iostream:72)
      ==31992==    by 0x49FF49C: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x48F7C1B: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 20 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x495DA00: global constructors keyed to FileRejectBody.cpp (iostream:72)
      ==31992==    by 0x49FF49C: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x48F7C1B: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 21 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x493B660: global constructors keyed to ClusterConnectionTxStartBody.cpp (iostream:72)
      ==31992==    by 0x49FF49C: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x48F7C1B: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 22 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x49B9380: global constructors keyed to AMQFrame.cpp (iostream:72)
      ==31992==    by 0x49FF49C: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x48F7C1B: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 23 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x49947C0: global constructors keyed to FileStageBody.cpp (iostream:72)
      ==31992==    by 0x49FF49C: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x48F7C1B: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 24 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x4924FF0: global constructors keyed to ClusterInitialStatusBody.cpp (iostream:72)
      ==31992==    by 0x49FF49C: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x48F7C1B: ??? (in /usr/local/lib/libqpidcommon.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 25 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x47C60D3: global constructors keyed to SessionImpl.cpp (iostream:72)
      ==31992==    by 0x47E1C3C: ??? (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==31992==    by 0x4781B43: ??? (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 26 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x47AE9AC: global constructors keyed to Demux.cpp (iostream:72)
      ==31992==    by 0x47E1C3C: ??? (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==31992==    by 0x4781B43: ??? (in /usr/local/lib/libqpidclient.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 27 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x471B352: global constructors keyed to OutgoingMessage.cpp (OutgoingMessage.cpp:46)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 28 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x4705CAB: global constructors keyed to AddressResolution.cpp (AddressResolution.cpp:101)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 520 bytes in 1 blocks are still reachable in loss record 29 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x41A14A0: __new_exitfn (cxa_atexit.c:101)
      ==31992==    by 0x41A1534: __internal_atexit (cxa_atexit.c:35)
      ==31992==    by 0x41A15A4: __cxa_atexit (cxa_atexit.c:58)
      ==31992==    by 0x46ED533: global constructors keyed to Address.cpp (Address.cpp:35)
      ==31992==    by 0x47308FC: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x46EA143: ??? (in /usr/local/lib/libqpidmessaging.so.2.0.0)
      ==31992==    by 0x400DBCB: call_init (dl-init.c:70)
      ==31992==    by 0x400DCE8: _dl_init (dl-init.c:134)
      ==31992==    by 0x4011D78: dl_open_worker (dl-open.c:463)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==
      ==31992== 544 bytes in 10 blocks are still reachable in loss record 30 of 33
      ==31992==    at 0x4023F50: malloc (vg_replace_malloc.c:236)
      ==31992==    by 0x400C1FE: _dl_map_object_deps (dl-deps.c:470)
      ==31992==    by 0x4011B80: dl_open_worker (dl-open.c:262)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034B40: dlopen@@GLIBC_2.1 (dlopen.c:88)
      ==31992==    by 0x80487D0: main (loader.cpp:6)
      ==31992==
      ==31992== 628 bytes in 1 blocks are still reachable in loss record 31 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x4009E52: _dl_new_object (dl-object.c:52)
      ==31992==    by 0x40059B7: _dl_map_object_from_fd (dl-load.c:969)
      ==31992==    by 0x4007133: _dl_map_object (dl-load.c:2240)
      ==31992==    by 0x4011B25: dl_open_worker (dl-open.c:225)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034B40: dlopen@@GLIBC_2.1 (dlopen.c:88)
      ==31992==    by 0x80487D0: main (loader.cpp:6)
      ==31992==
      ==31992== 2,112 bytes in 11 blocks are still reachable in loss record 32 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x400F247: _dl_check_map_versions (dl-version.c:299)
      ==31992==    by 0x4011DC8: dl_open_worker (dl-open.c:268)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x403509B: _dlerror_run (dlerror.c:164)
      ==31992==    by 0x4034B40: dlopen@@GLIBC_2.1 (dlopen.c:88)
      ==31992==    by 0x80487D0: main (loader.cpp:6)
      ==31992==
      ==31992== 6,369 bytes in 10 blocks are still reachable in loss record 33 of 33
      ==31992==    at 0x402328F: calloc (vg_replace_malloc.c:467)
      ==31992==    by 0x4009E52: _dl_new_object (dl-object.c:52)
      ==31992==    by 0x40059B7: _dl_map_object_from_fd (dl-load.c:969)
      ==31992==    by 0x4007133: _dl_map_object (dl-load.c:2240)
      ==31992==    by 0x400CE9B: openaux (dl-deps.c:65)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x400C191: _dl_map_object_deps (dl-deps.c:247)
      ==31992==    by 0x4011B80: dl_open_worker (dl-open.c:262)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==    by 0x40115C5: _dl_open (dl-open.c:554)
      ==31992==    by 0x4034C0A: dlopen_doit (dlopen.c:67)
      ==31992==    by 0x400D7F5: _dl_catch_error (dl-error.c:178)
      ==31992==
      ==31992== LEAK SUMMARY:
      ==31992==    definitely lost: 0 bytes in 0 blocks
      ==31992==    indirectly lost: 0 bytes in 0 blocks
      ==31992==      possibly lost: 334 bytes in 11 blocks
      ==31992==    still reachable: 17,155 bytes in 74 blocks
      ==31992==         suppressed: 0 bytes in 0 blocks
      ==31992==
      ==31992== For counts of detected and suppressed errors, rerun with: -v
      ==31992== ERROR SUMMARY: 12 errors from 12 contexts (suppressed: 42 from 9)
      Segmentation fault
      

      Relevance

      The reason I'm bothering to try to understand / fix such a scenario, is because this is precisely (or at least very close) to what happens with the PHP binding I've been working on, if the PHP processors completes very quickly (you can see some background info at https://issues.apache.org/jira/browse/QPID-3027).

      Basically, the PHP plugin is compiled against libqpidmessaging, and the PHP CLI interpreter dlopen's and then dlclose's my plugin, resulting in the same segfault, at the same location (though in that case, gdb's backtrace includes info similar to Valgrind's output above (ie shows the segfault to be in __cxa_finalize, called within libqpidmessaging)).

      If there is anything more I can report, or any tests / experiments worth carrying out, please let me know!

      Attachments

        1. loadee.cpp
          0.0 kB
          Paul Colby
        2. loader.cpp
          0.4 kB
          Paul Colby
        3. Makefile
          0.2 kB
          Paul Colby

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pcolby Paul Colby
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: