DECLARE_DYNAMIC_CLASS ~wxClassInfo and Shared Object

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ddaeschl
Knows some wx things
Knows some wx things
Posts: 41
Joined: Wed Oct 27, 2004 6:06 pm
Location: Western NY
Contact:

DECLARE_DYNAMIC_CLASS ~wxClassInfo and Shared Object

Post by ddaeschl »

I have an application that only uses the wxbase, and wxodbc libraries, but loads addon modules. These addon modules can be used with the application in question, or another application that supports a GUI, so the addins may load other WX libraries. So I call wxInitialize on startup and wxUninitialize on shutdown in this app because I use the main function to start out instead of wxapp.

Everything works fine until I want to terminate the application. I proceed to unload the libraries, which works fine. But then, after the IP drops out of my main function I get a segmentation fault with the following info from gdb and a debug version of WX.

Code: Select all

(gdb) bt
#0  0x001e3466 in ~wxClassInfo (this=0x271afc) at ./src/common/object.cpp:187
#1  0x001909d0 in __tcf_1 () at ./src/common/archive.cpp:30
#2  0x0029fdaf in __cxa_finalize () from /lib/libc.so.6
#3  0x0018da2a in __do_global_dtors_aux ()
   from /home/ddaeschl/srcbuilds/wxGTK-2.6.1/lib/libwx_based-2.6.so.0
#4  0x002342be in _fini ()
   from /home/ddaeschl/srcbuilds/wxGTK-2.6.1/lib/libwx_based-2.6.so.0
#5  0x004f32d8 in _dl_fini () from /lib/ld-linux.so.2
#6  0x0029fba9 in exit () from /lib/libc.so.6
#7  0x00289d67 in __libc_start_main () from /lib/libc.so.6
#8  0x080e3609 in _start ()
(gdb) f 0
#0  0x001e3466 in ~wxClassInfo (this=0x271afc) at ./src/common/object.cpp:187
187                 if ( info->m_next == this )
(gdb) list
182         else
183         {
184             wxClassInfo *info = sm_first;
185             while (info)
186             {
187                 if ( info->m_next == this )
188                 {
189                     info->m_next = m_next;
190                     break;
191                 }
(gdb) f 1
#1  0x001909d0 in __tcf_1 () at ./src/common/archive.cpp:30
30      IMPLEMENT_ABSTRACT_CLASS(wxArchiveClassFactory, wxObject)
(gdb) list
25      #if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
26
27      #include "wx/archive.h"
28
29      IMPLEMENT_ABSTRACT_CLASS(wxArchiveEntry, wxObject)
30      IMPLEMENT_ABSTRACT_CLASS(wxArchiveClassFactory, wxObject)
31
32      #if wxUSE_ZIPSTREAM
33      //FORCE_LINK(zipstrm)
34      extern int _wx_link_dummy_func_zipstrm();
(gdb)
It looks like wxbase is going through a chain of class info that still has one of the classes from an unloaded DLL in it! As far as I know, upon execution of the static destructors in my Addon library the classes that were declared with IMPLEMENT_DYNAMIC_CLASS should be unregistered. But it appears either the static dtors are not getting called, or wx is not unregistering my classes.

Does anyone have any ideas?

Linux i686, gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
wxGTK 2.6.1
Post Reply