KLibLoader is crashing

Rafael Fernández López ereslibre at gmail.com
Mon Sep 3 02:38:27 BST 2007

This is worse than I thought.

I will enumerate the different crashes I have been experiencing by trying.

- 1st crash
- Open KWrite
- Go to Extensions page
- Be sure the "Word Completion" plugin is enabled. It is the one that
has configuration dialog.
- Open the configuration dialog by clicking on "Settings" button.
- Click "OK" or "Cancel"
- Click "OK" or "Cancel"

- 2nd crash
- Open Kopete
- Go to the Settings Dialog
- Go to the Plugins page
- Click on a "Settings" button of an already loaded plugin
- Click "OK" or "Cancel"
- Click "OK" or "Cancel"

- 3rd crash
- Open Kopete
- Go the Settings Dialog
- Click on "OK" or "Cancel"
- Go to the Settings Dialog

- 4th crash
- Open Kopete
- Go to the Settings Dialog
- Click on "OK" or "Cancel"
- Wait some seconds


Now. Some good news. 1st and 2nd crash are the same crash. 3rd and 4th
crash have different origins. Between each other too.

- 1st and 2nd crash

Take a look at the attached patch kutils.diff. The problem is that the
destructor of the class KCModuleProxy:


	delete d_ptr;

unloads the module, what leads us to:

void KCModuleLoader::unloadModule(const KCModuleInfo &mod)
  // get the library loader instance
  KLibLoader *loader = KLibLoader::self();

  // try to unload the library
  QString libname("lib%1");


This _IS_ a problem. Always the library is tried to be removed. I
found the problem that sometimes the ref counting wasn't incremented,
under certain conditions (look at the patch). If we always try to
unload the library, we always want to increase the ref counting.

This fixed the kind of crash 1st and 2nd.

3rd crash: I'm completely unable to catch this one. Have tried with no
success. I mean, have tried _very_ hard. Cannot find that one.

4th crash: I found something quite interesting at KLibrary:

void KLibrary::slotObjectCreated( QObject *obj )
  .... code ...

  connect( obj, SIGNAL( destroyed() ),
           this, SLOT( slotObjectDestroyed() ) );

  ..... code ....

void KLibrary::slotObjectDestroyed()
 .... code .....

    if ( !d->timer )
      d->timer = new QTimer( this );
      d->timer->setObjectName( QLatin1String("klibrary_shutdown_timer") );
      connect( d->timer, SIGNAL( timeout() ),
               this, SLOT( slotTimeout() ) );

    // as long as it's not stable make the timeout short, for debugging
    // pleasure (matz)
    //d->timer->start( 1000*60 );
    d->timer->start( 1000*10 );

... code ...


void KLibrary::slotTimeout()
  if ( d->objs.count() != 0 )

  /* Don't go through KLibLoader::unloadLibrary(), because that uses the
     ref counter, but this timeout means to unconditionally close this library
     The destroyed() signal will take care to remove us from all lists.
  delete this;

So, the other attached file (kdecore.diff) comments out this last
"delete this", and seems to fix the 4th crash. Of course, fix for
saying something. This is _NOT_ a fix. It also adds some output by
console about the refcounting.

This errors are not trivial, and should be fixed. For that reason I
would like that if you guys have time put an eye on this. This makes
lots of things to crash.

I have also noticed (since the plugin system change) that KWin plugin
configuration dialogs throws an error on finding the KCM of the
plugins that have configuration dialog. I didn't even look at that, I
didn't have time, but it shouldn't be a hard thing. If nobody fixes it
I will give it some minutes when I can.

Rafael Fernández López.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kutils.diff
Type: text/x-diff
Size: 1502 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070903/e33d62e7/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdecore.diff
Type: text/x-diff
Size: 1843 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070903/e33d62e7/attachment-0001.diff>

More information about the kde-core-devel mailing list