Review Request: Introduce two new KCrash methods: void setLaunchDrKonqi(bool) and bool launchDrKonqi().

George Kiagiadakis at
Mon Oct 26 09:37:06 GMT 2009

This is an automatically generated e-mail. To reply, visit:

(Updated 2009-10-26 09:37:06.651895)

Review request for kdelibs.


Change the method names as suggested by Thiago and Chani and also improve their documentation.


This patch introduces two new methods in the KCrash namespace: void setLaunchDrKonqi(bool) and bool launchDrKonqi(). The reason for introducing these functions is simple. At the moment, the KCrash::setCrashHandler function enables launching drkonqi on a crash if its argument is the default crash handler, but the setEmergencySaveFunction() and setFlags(AutoRestart) methods disable it completely if it was not previously enabled, so for example, the following code both launches drkonqi and calls the emergency save function on a crash:


...but the following code only calls the emergency save function on a crash:


This happens because setEmergencySaveFunction will set the internal s_launchDrKonqi variable to false if it finds that no crash handler has been already installed and after that, there is no way to make this variable true again. By separating the function of enabling/disabling drkonqi from the function of setting the crash handler (which is a completely different thing...), we have more control over the behavior of KCrash and we eliminate weird behavior like in the above example.

Note that with this patch, the behavior of the KCrash API changes a little bit. Now, if someone wants to enable launching drkonqi for his application's crashes without using KApplication, he has to use KCrash::setLaunchDrKonqi(true) and not just KCrash::setCrashHandler(KCrash::defaultCrashHandler). Setting the crash handler to the default one no more has any visible effect if none of its functionality is explicitly enabled. Fortunately, by looking at, it seems that in our svn there is only one application that uses setCrashHandler() with the semantic of enabling drkonqi and that is the kdm greeter, which I can easily patch when this patch is in kdelibs.

The real reason that motivated me to write this patch is drkonqi itself. As it grows more complex with each kde release, it is possible that it crashes just like any other kde application. Currently, catching crashes of drkonqi with drkonqi is disabled, but I want to enable it in a safe way. My algorithm involves the following steps:
1) set the KDE_DEBUG environment variable to true so that KApplication does not set the crash handler.
2) initialize KApplication and the drkonqi backend that will give us information about the crashed application. This involves setting an emergency save function that will kill the crashed app if drkonqi crashes, as drkonqi keeps the crashed app in a stopped state (SIGSTOP) while it is running. If drkonqi crashes, there is nobody that will continue/kill the crashed app, so this emergency save function is necessary.
3) now that the backend is functional and can give us information about the crashed app, if the app is *not* drkonqi itself, set the crash handler so that drkonqi can catch its own crash. This step ensures that drkonqi will not start spawning itself recursively if for instance it crashes at startup for some random reason, but it will still enable us to catch some rare crash in some specific function.

With the current KCrash API, it is impossible to implement this algorithm, unless steps 2 and 3 are reversed, but that breaks the whole backend-based design, which I'd rather not do. Of course, I didn't write this patch only for supporting this functionality in drkonqi. I think it is a nice improvement to this API, since the current one behaves weird, as demonstrated above.

Diffs (updated)

  /trunk/KDE/kdelibs/kdeui/kernel/kapplication.cpp 1040176 
  /trunk/KDE/kdelibs/kdeui/util/kcrash.h 1040176 
  /trunk/KDE/kdelibs/kdeui/util/kcrash.cpp 1040176 



Application crashes are still handled fine with drkonqi without changing the applications and drkonqi can now catch its own crashes just fine.



More information about the kde-core-devel mailing list