Race condition in KUniqueApplication
Krzysztof Lichota
krzysiek at lichota.net
Tue Mar 27 09:24:30 BST 2007
While investigating Ark bug I have come across possible race condition
in KUniqueApplication.
It does the following (if --nofork is not set):
- fork a child
- child checks if application is running, if not spawns it
- child reports to parent using pipe if application is running
- parent sends to application DCOP call to create new instance
- if DCOP call fails, it just aborts
If application is during shutdown (which happens often with Ark when it
is unpacking files), the check for application running in child is
successful, while the DCOP call in parent fails and starting app fails.
IMO the right thing to do would be to make DCOP call in child and repeat
call (and spawning the process) if it fails. This involves many changes
in the code, so I tried the other approach: repeat everything in parent
process. This works much better (although does not solve Ark bug
completely, so I have to investigate it further).
Anyway, the patch (preliminary, it is not intended for applying) is
attached, what do you think of this whole problem? Have I missed
something? Should I try to move the DCOP call and loop in child?
BTW. I wonder who got the idea to remove arguments from command line in
KCmdLineArgs::saveAppArgs() - I would expect functions with "save" in
name to not modify things they save... The patch contains fix for this,
but I am not sure it should be applied, this might have some side
effects. Looping and making the DCOP call in child would solve race
condition without changing KCmdLineArgs::saveAppArgs().
Krzysztof Lichota
PS. The for(;;) loop in patch should be replaced with some limited
number of loops to avoid possible fork bomb.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kuniqueapplication-race-condition.diff
Type: text/x-patch
Size: 2374 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070327/c18ed571/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070327/c18ed571/attachment.sig>
More information about the kde-core-devel
mailing list