MSUdom5
11th June 2013, 21:41
I've run into an interesting situation that causes unpredictable segfaults when my application exits. I tried to isolate an example in a small project, but was unable to reproduce it. I think I know the cause, but would like an expert's opinion.
I have a static libary, FooLib, which contains several classes (including an abstract base class, FooInterface). Some classes have static member data. I also have a Qt Plugin, FooPlugin, which depends on FooLib and implements FooInterface. My main application also depends on FooLib.
I'm able to load the plugin and use it without any issues. However, when the application exits, I get a segfault. (If I run it through a debugger, there is not segfault, so I can't get a stack trace). If I remove all static member data from the classes in FooLib, the segfault goes away.
My guess is that the static member data is being deleted twice, once when FooPlugin is unloaded, and again when FooLib classes (instatiated in my main application) are destructed.
Any thoughts from experts?
Thanks ,
I have a static libary, FooLib, which contains several classes (including an abstract base class, FooInterface). Some classes have static member data. I also have a Qt Plugin, FooPlugin, which depends on FooLib and implements FooInterface. My main application also depends on FooLib.
I'm able to load the plugin and use it without any issues. However, when the application exits, I get a segfault. (If I run it through a debugger, there is not segfault, so I can't get a stack trace). If I remove all static member data from the classes in FooLib, the segfault goes away.
My guess is that the static member data is being deleted twice, once when FooPlugin is unloaded, and again when FooLib classes (instatiated in my main application) are destructed.
Any thoughts from experts?
Thanks ,