Results 1 to 2 of 2

Thread: Qt Plugin causing segmentation faults

  1. #1
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Qt Plugin causing segmentation faults

    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 ,

  2. #2
    Join Date
    Feb 2013
    Location
    India
    Posts
    153
    Thanks
    27
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt Plugin causing segmentation faults

    I have got the same problem in my APP.
    Then i debug it and found that, I have created a static pointer in a class and and the pointer gets deleted whenever the object of that class is deleted.

    The cause happen when i use the same static variable class in my parent as well as child class.

    One more mistake i have made is that i have created an object of static variable class in main.cpp and also created object in mainwindow.cpp....
    :P
    If you accessing the deleted object then obviously it cause ERROR...

Similar Threads

  1. Segmentation Fault after plugin was unloaded
    By zzz9 in forum Qt Programming
    Replies: 6
    Last Post: 3rd October 2011, 16:41
  2. QTcpSocket.readLine causing segmentation failure
    By hasnain in forum Qt Programming
    Replies: 1
    Last Post: 4th September 2010, 16:00
  3. Plugin Segmentation fault
    By vieraci in forum Qt Programming
    Replies: 2
    Last Post: 31st July 2009, 07:33
  4. Seg faults in windows
    By giusepped in forum Qt Programming
    Replies: 3
    Last Post: 16th December 2008, 13:37
  5. page faults
    By moowy in forum General Programming
    Replies: 2
    Last Post: 20th January 2007, 14:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.