[espie at nerim.net: PATCH: fix nasty race condition in core libraries]

Waldo Bastian bastian at kde.org
Mon Jan 31 22:41:39 GMT 2005


Please commit.

Cheers,
Waldo

On Monday 31 January 2005 20:37, Marc Espie wrote:
> Prompted by Stephen Kulow...
>
> ----- Forwarded message from Marc Espie <espie at nerim.net> -----
>
> Date: Sat, 29 Jan 2005 14:29:09 +0100
> From: Marc Espie <espie at nerim.net>
> To: kde-devel at kde.org
> Subject: PATCH: fix nasty race condition in core libraries
>
> I've finally found out why kded crashes frequently when one starts
> konqueror directly on OpenBSD.
>
> It's because of the following race condition.
>
> For some reason, it doesn't happen (or doesn't happen that often) under
> other OSes, but it is fairly deadly. Having setupHandlers in the
> KProcessController constructor means the sigchild handler may get called
> before theKProcessController has finished building, and the ::write ends
> in a segfault.
>
> Under OpenBSD, the way threads are implemented mean the SIGCHLD happens
> right away when we do the sigprocmask, whereas for other OSes it might
> happen infrequently.
>
> I'd like to commit this before the new KDE gets released...
>
> Any objection ?
>
> Index: kprocctrl.cpp
> ===================================================================
> RCS file: /home/kde/kdelibs/kdecore/kprocctrl.cpp,v
> retrieving revision 1.59
> diff -u -p -u -p -r1.59 kprocctrl.cpp
> --- kprocctrl.cpp	7 Sep 2004 11:42:17 -0000	1.59
> +++ kprocctrl.cpp	29 Jan 2005 11:32:46 -0000
> @@ -39,7 +39,10 @@ int KProcessController::refCount;
>  void KProcessController::ref()
>  {
>    if( !refCount )
> +  {
>      theKProcessController = new KProcessController;
> +    setupHandlers();
> +  }
>    refCount++;
>  }
>
> @@ -71,7 +74,6 @@ KProcessController::KProcessController()
>    QObject::connect( notifier, SIGNAL(activated(int)),
>                      SLOT(slotDoHousekeeping()));
>
> -  setupHandlers();
>  }
>
>  KProcessController::~KProcessController()
>
> ----- End forwarded message -----

-- 
bastian at kde.org   |   Free Novell Linux Desktop 9 Evaluation Download
bastian at suse.com  |   http://www.novell.com/products/desktop/eval.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050131/466bb022/attachment.sig>


More information about the kde-core-devel mailing list