Patch to disarm timers after an exec syscall
Subsystems (2)
Hi all,
while running the openposix testsuite I saw testcase timer_create/9-1.c failing. This testcase tests whether timers are disarmed when a process calls exec, as described in e.g.
http://www.opengroup.org/onlinepubs/009695399/functions/timer_create.html.
The attached one-liner patch (+ one line comment) fixes this issue. I did the diff against 2.6.12.1, but the fix is pretty much the same for every other 2.6.x kernel I had a look at.
I don't think this patch breaks anything, as relying on this (undocumented) behaviour would imho be bad style.
So tell me what you think, and if you have some pointers to interesting discussions about Linux and POSIX compliance then I would like to read that as well.
mfg
Gernot
fs/exec.c +4 -0
@@ -1200,6 +1200,10 @@acct_update_integrals (current);update_mem_hiwater (current);kfree (bprm); + +/* delete old itimers */ +exit_itimers (current->signal); +return retval; }
Quoted 17 lines · Gernot Payer
while running the openposix testsuite I saw testcase timer_create/9-1.c
failing. This testcase tests whether timers are disarmed when a process calls exec, as described in e.g.
http://www.opengroup.org/onlinepubs/009695399/functions/timer_create.html.The attached one-liner patch (+ one line comment) fixes this issue. I did the diff against 2.6.12.1, but the fix is pretty much the same for every other 2.6.x kernel I had a look at.
I don't think this patch breaks anything, as relying on this (undocumented) behaviour would imho be bad style.
So tell me what you think, and if you have some pointers to interesting discussions about Linux and POSIX compliance then I would like to read that as well.
Quoted 12 lines
---
linux-2.6.12.1-orig/fs/exec.c2005-06-29 14:29:31.069738264 +0200
+++linux-2.6.12.1/fs/exec.c2005-06-29 14:34:46.034856288 +0200
@@ -1200,6 +1200,10 @@
acct_update_integrals(current);
update_mem_hiwater(current);
kfree(bprm);
+
+ /* delete old itimers */
+exit_itimers(current->signal);
+
return retval;
}
Ouch. What does 2.4.x do?
It wouldn't surprise me if fixing this breaks _something_ out there. We might have to remain non-POSIX-compliant for the rest of time.
Quoted 11 lines · * Gernot Payer ([email protected]) wrote:
Hi all,
while running the openposix testsuite I saw testcase timer_create/9-1.c failing. This testcase tests whether timers are disarmed when a process calls exec, as described in e.g.
http://www.opengroup.org/onlinepubs/009695399/functions/timer_create.html.The attached one-liner patch (+ one line comment) fixes this issue. I did the diff against 2.6.12.1, but the fix is pretty much the same for every other 2.6.x kernel I had a look at.
No, this can't do. It conflicts with the other bit of requirements. Specifically:
http://www.opengroup.org/onlinepubs/009695399/functions/exec.html
As you mention:
[TMR] Per-process timers created by the calling process shall be deleted before replacing the current process image with the new process image.
But also:
The new process shall inherit at least the following attributes from the calling process image:
<snip>
o [XSI] Interval timers
And this kills the latter.
thanks,
-chris
Quoted 1 line · * Andrew Morton ([email protected]) wrote:
Ouch. What does 2.4.x do?
Does 2.4 even support realtime timers?
Quoted 2 lines
It wouldn't surprise me if fixing this breaks _something_ out there. We might have to remain non-POSIX-compliant for the rest of time.
But I agree, the fix is wrong as it at least breaks compliance with itimers.
thanks,
-chris
In the current code, de_thread already calls exit_itimers to address exactly this issue. Can someone please send me the test case that demonstrates this is not working right?
Thanks,
Roland
Quoted 10 lines · Chris Wright
No, this can't do. It conflicts with the other bit of requirements. Specifically:
http://www.opengroup.org/onlinepubs/009695399/functions/exec.htmlAs you mention:
[TMR] Per-process timers created by the calling process shall be deleted before replacing the current process image with the new process image.
Quoted 8 lines
But also:
The new process shall inherit at least the following attributes from the calling process image:
<snip>
o [XSI] Interval timersAnd this kills the latter.
Ah, thanks for pointing that out. Unfortunately this fact isn't made clear in the timer_create page and the exec page isn't very understandable for non-native speakers and non-lawyers. ;-)
But after reading the parts you mentioned (expecially the [XSI] and [TMR] acronyms), I have to agree with you, the patch is wrong and so is the test case I mentioned.
However, poking around in the kernel was fun anyway. ;-)
Quoted 2 lines
thanks,
-chris
mfg
Gernot
Quoted 3 lines · Roland McGrath
In the current code,
de_threadalready callsexit_itimersto address exactly this issue. Can someone please send me the test case that demonstrates this is not working right?
This test case can be found here:
But as already mentioned in this thread, this test case is wrong.
Quoted 2 lines
Thanks,
Roland
mfg
Gernot