Bug 82617 - crash when exit using File->Quit
Summary: crash when exit using File->Quit
Status: RESOLVED FIXED
Alias: None
Product: klinkstatus
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: CVS HEAD
Platform: Compiled Sources Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: Paulo Moura Guedes
URL:
Keywords:
: 99309 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-06-01 03:42 UTC by Paulo Moura Guedes
Modified: 2006-04-27 11:13 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paulo Moura Guedes 2004-06-01 03:42:13 UTC
Version:           0.1.2 (CVS) (using KDE KDE 3.2.2)
Installed from:    Compiled From Sources
OS:                Linux

The crash doesn't happens if X or alt-F4 are used to quit the application.

Backtrace:
#0  0x40dc5998 in QGList::find(void*, bool) () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#1  0x4073f7ae in KGlobal::registerStaticDeleter(KStaticDeleterBase*) () from /usr/lib/libkdecore.so.4
#2  0x41687a03 in KStaticDeleter<KLSConfig>::setObject(KLSConfig*&, KLSConfig*, bool) (this=0x416af594,
    globalRef=@0x416af590, obj=0x8175c28, isArray=false) at kstaticdeleter.h:101
#3  0x41686c1d in KLSConfig::self() () at klsconfig.cpp:14
#4  0x41682528 in KLSConfig::setComboUrlHistory(QStringList const&) (v=@0xbffff110) at klsconfig.h:78
#5  0x41680fae in KLSHistoryCombo::saveItems() (this=0x8177900)
    at /home/mojo/programacao/kde/kdewebdev/klinkstatus/src/ui/klshistorycombo.cpp:54
#6  0x4167402a in ~SessionWidget (this=0x816d898)
    at /home/mojo/programacao/kde/kdewebdev/klinkstatus/src/ui/sessionwidget.cpp:74
#7  0x40b4920d in QWidget::~QWidget() () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#8  0x40c54af6 in QWidgetStack::~QWidgetStack() () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#9  0x40b4920d in QWidget::~QWidget() () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#10 0x40c3eb12 in QTabWidget::~QTabWidget() () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#11 0x4167f87a in ~TabWidgetSession (this=0x81652f0)
    at /home/mojo/programacao/kde/kdewebdev/klinkstatus/src/ui/tabwidgetsession.cpp:48
#12 0x40035eea in KParts::Part::~Part() () from /usr/lib/libkparts.so.2
#13 0x400367cd in KParts::ReadOnlyPart::~ReadOnlyPart() () from /usr/lib/libkparts.so.2
#14 0x4166ce9b in ~KLinkStatusPart (this=0x8156a98)
    at /home/mojo/programacao/kde/kdewebdev/klinkstatus/src/klinkstatus_part.cpp:72
#15 0x4056f1be in QPtrList<QObject>::deleteItem(void*) () from /usr/lib/libkdeui.so.4
#16 0x40dc58fe in QGList::clear() () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#17 0x4074b003 in KLibrary::~KLibrary() () from /usr/lib/libkdecore.so.4
#18 0x4074cb99 in KLibLoader::close_pending(KLibWrapPrivate*) () from /usr/lib/libkdecore.so.4
#19 0x4074c0fa in KLibLoader::~KLibLoader() () from /usr/lib/libkdecore.so.4
#20 0x4074bb68 in KLibLoader::cleanUp() () from /usr/lib/libkdecore.so.4
#21 0x406a434b in KApplication::~KApplication() () from /usr/lib/libkdecore.so.4
#22 0x0804fe76 in main (argc=1, argv=0xbffff694) at /home/mojo/programacao/kde/kdewebdev/klinkstatus/src/main.cpp:93
Comment 1 Amilcar do Carmo Lucas 2004-09-28 17:57:05 UTC
New bt:
Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 1095468256 (LWP 3742)]
[KCrash handler]
#7  0x41728450 in LinkStatus::setChecked (this=0x17, flag=true)
    at linkstatus_impl.h:145
#8  0x4172684c in LinkChecker::finnish (this=0x1d88a650)
    at /mnt/home/be/sources/kde/kdewebdev/klinkstatus/src/engine/linkchecker.cpp:406
#9  0x4172636c in LinkChecker::slotResult (this=0x1d88a650)
    at /mnt/home/be/sources/kde/kdewebdev/klinkstatus/src/engine/linkchecker.cpp:333
#10 0x41727578 in LinkChecker::qt_invoke (this=0x1d88a650, _id=5, 
    _o=0xbfffd050) at linkchecker.moc:152
#11 0x40bd623e in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#12 0x401809f2 in KIO::Job::result () from /opt/kde3/lib/libkio.so.4
#13 0x401d878c in KIO::Job::emitResult () from /opt/kde3/lib/libkio.so.4
#14 0x401e17ec in KIO::SimpleJob::slotFinished ()
   from /opt/kde3/lib/libkio.so.4
#15 0x401e1dca in KIO::TransferJob::slotFinished ()
   from /opt/kde3/lib/libkio.so.4
#16 0x401cf167 in KIO::TransferJob::qt_invoke () from /opt/kde3/lib/libkio.so.4
#17 0x40bd623e in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#18 0x40bd69e6 in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#19 0x40185d0c in KIO::SlaveInterface::finished ()
   from /opt/kde3/lib/libkio.so.4
Comment 2 Paulo Moura Guedes 2004-09-28 18:03:26 UTC
Thanks for your bt!
I noticed that it begins on #7. If it's useful after that can you send me the complete bt?
Anyway I think this is a diferent bug, that is caused by interrupting the checking. The original one is just caused by:
1. Run KLinkStatus
2. File -> Quit
Comment 3 estevam 2004-10-29 00:16:00 UTC
The same problem in my Suse vr.

Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 1095476448 (LWP 19557)]
[KCrash handler]
#7  0x40e97388 in QGList::find () from /usr/lib/qt3/lib/libqt-mt.so.3
#8  0x407617dc in KGlobal::registerStaticDeleter ()
   from /opt/kde3/lib/libkdecore.so.4
#9  0x407dd9f2 in KSharedConfig::KSharedConfig ()
   from /opt/kde3/lib/libkdecore.so.4
#10 0x407ddba0 in KSharedConfig::openConfig ()
   from /opt/kde3/lib/libkdecore.so.4
#11 0x407df0e6 in KConfigSkeleton::KConfigSkeleton ()
   from /opt/kde3/lib/libkdecore.so.4
#12 0x4171296d in KLSConfig::KLSConfig ()
   from /opt/kde3/lib/kde3/libklinkstatuspart.so
#13 0xbfffec40 in ?? ()
#14 0xffffffff in ?? ()
#15 0x41372450 in __JCR_LIST__ () from /usr/lib/libstdc++.so.5
#16 0xbfffecb0 in ?? ()
#17 0x4172a543 in typeinfo name for QMemArray<int> ()
   from /opt/kde3/lib/kde3/libklinkstatuspart.so
#18 0x414b6520 in __malloc_initialize_hook () from /lib/tls/libc.so.6
#19 0x4135124d in operator new[] () from /usr/lib/libstdc++.so.5
Comment 4 Ilpo Kantonen 2004-11-03 00:09:02 UTC
Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -151133152 (LWP 9273)]
[KCrash handler]
#4  0x01424e18 in QGList::find () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#5  0x00534d1e in KGlobal::registerStaticDeleter ()
   from /usr/lib/libkdecore.so.4
#6  0x005bc89b in KStaticDeleter<QValueList<KSharedConfig*> >::setObject ()
   from /usr/lib/libkdecore.so.4
#7  0x004c9c25 in KSharedConfig::KSharedConfig ()
   from /usr/lib/libkdecore.so.4
#8  0x004c997b in KSharedConfig::openConfig () from /usr/lib/libkdecore.so.4
#9  0x0059b3d8 in KConfigSkeleton::KConfigSkeleton ()
   from /usr/lib/libkdecore.so.4
#10 0x02e6e8e0 in KLSConfig (this=0x8ba4778) at klsconfig.cpp:23
#11 0x02e6dccb in KLSConfig::self () at kstaticdeleter.h:104
#12 0x02e68343 in KLSHistoryCombo::saveItems (this=0x0) at klsconfig.h:78
#13 0x02e5ec61 in ~SessionWidget (this=0x8adb520) at sessionwidget.cpp:75
#14 0x0119cb5d in QWidget::~QWidget () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#15 0x012accf6 in QWidgetStack::~QWidgetStack ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#16 0x0119cb5d in QWidget::~QWidget () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#17 0x01296802 in QTabWidget::~QTabWidget ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#18 0x02e66f8d in ~TabWidgetSession (this=0x8ac8328) at qintdict.h:56
#19 0x00ed320a in KParts::Part::~Part () from /usr/lib/libkparts.so.2
#20 0x00ed3aed in KParts::ReadOnlyPart::~ReadOnlyPart ()
   from /usr/lib/libkparts.so.2
#21 0x02e562c9 in ~KLinkStatusPart (this=0x8abb628) at klinkstatus_part.cpp:74
#22 0x00389ece in QPtrList<QObject>::deleteItem () from /usr/lib/libkdeui.so.4
#23 0x01424d7e in QGList::clear () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#24 0x0053e963 in KLibrary::~KLibrary () from /usr/lib/libkdecore.so.4
#25 0x00540626 in KLibLoader::close_pending () from /usr/lib/libkdecore.so.4
#26 0x0053fa7a in KLibLoader::~KLibLoader () from /usr/lib/libkdecore.so.4
#27 0x0053f4c8 in KLibLoader::cleanUp () from /usr/lib/libkdecore.so.4
#28 0x004a30a1 in KApplication::~KApplication () from /usr/lib/libkdecore.so.4
#29 0x0805009e in main ()
Comment 5 Ben Burton 2005-02-07 23:24:38 UTC
Hi.  A debian user has also reported this issue (#293495).  Again the segfault only happens if you exit while the links are being checked, and again it only happens if you use File->Quit.  Given this however, it's completely reproducible on my system.

The debian user's backtrace is available at http://bugs.debian.org/293495 .

Ben.
Comment 6 Paulo Moura Guedes 2005-02-08 03:48:50 UTC
Hi,

I have this code:

KLSConfig *KLSConfig::self()
{
  if ( !mSelf ) {
    staticKLSConfigDeleter.setObject( mSelf, new KLSConfig() );
    mSelf->readConfig();
  }
  return mSelf;
}

and I'm having a crash on the line "setObject" is called.

kglobal_init() returns with "addedFreeAll" and then 
"KGlobal::registerStaticDeleter" crashes when trying to use a null 
"_staticDeleters" pointer:

static void kglobal_init()
{
    if (addedFreeAll)
        return;

    addedFreeAll = true;
    KGlobal::_staticDeleters = new KStaticDeleterList;

    qAddPostRoutine( kglobal_freeAll );
}

void KGlobal::registerStaticDeleter(KStaticDeleterBase *obj)
{
   if (!_staticDeleters)
      kglobal_init();
   if (_staticDeleters->find(obj) == -1)
      _staticDeleters->append(obj);
}

This happens when quiting KLinkStatus using "File->Quit" (see #82617). If I 
use window button to close the application it doesn't crashes because the 
config singleton object, "mSelf", isn't removed (why the diference?). 

It's quite obvious that registerStaticDeleter() method should check if the 
pointer is valid but my question is if I'm doing something wrong.

Comment 7 Paulo Moura Guedes 2005-02-09 02:03:37 UTC
CVS commit by mojo: 

BUG: 82617

Crash when calling KApplication::quit().
The static deleters were being destructed first than SessionWidget object which was trying to use them in the destructor.

Thanks for the investigation work done by Waldo.


  M +17 -1     klinkstatus.cpp   1.14


--- kdewebdev/klinkstatus/src/klinkstatus.cpp  #1.13:1.14
@@ -98,5 +98,21 @@ void KLinkStatus::load(const KURL& url)
 void KLinkStatus::setupActions()
 {
-    KStdAction::quit(kapp, SLOT(quit()), actionCollection());
+    //     KStdAction::quit(kapp, SLOT(quit()), actionCollection()); 
+    // The above causes a segfault when using File->Quit.
+    // Here's Waldo's explanation:
+/*    I had a look. The problem is due to the SessionWidget destructor calling 
+    KLSConfig. If you use the window button, the window and the SessionWidget is 
+    destructed first and then later the application is destructed.
+    If you use File->Quit it calls kapp->quit which destructs the application 
+    without destructing the window first. The application first destructs all 
+    static deleters and its administration, and then goes on to kill the 
+    remaining windows that it owns. Therein lies the problem because by then the 
+    static deleters aren't usable any longer, and calling KLSConfig from the 
+    SessionWidget destructor crashes when it tries to recreate KLSConfig and 
+    register it with staticKLSConfigDeleter due to the lack of static deleter 
+    administration.
+    The easiest solution is to call close() on the mainwindow instead of 
+    KApplication::quit()*/
+    KStdAction::quit(this, SLOT(close()), actionCollection());
 
     //m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());


Comment 8 Paulo Moura Guedes 2005-02-13 23:57:10 UTC
*** Bug 99309 has been marked as a duplicate of this bug. ***