Page MenuHomeFreeBSD

Avoid EINTR when debugging.
Needs ReviewPublic

Authored by kib on Sep 13 2015, 1:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 9 2024, 9:14 PM
Unknown Object (File)
May 9 2024, 9:09 PM
Unknown Object (File)
May 9 2024, 3:46 PM
Unknown Object (File)
Jan 18 2024, 1:52 PM
Unknown Object (File)
Dec 19 2023, 11:29 PM
Unknown Object (File)
Dec 11 2023, 7:45 PM
Unknown Object (File)
Oct 3 2023, 1:11 AM
Unknown Object (File)
Aug 10 2023, 12:54 PM
Subscribers

Details

Reviewers
jmg
jhb
avg
Summary

I found this patch from really old times. I believe what I tried to do is to avoid spurious EINTR from system calls like select(2)/poll(2) and sleeps, which explicitely want to return EINTR for the signal interruption even when the signal disposition is flagged with SA_RESTART.

I have vague memory that the issue was reported by Andrey in context of udtrace, and that the patch has some issues, but I do not remember the outcome. I could revive it if this is considered interesting.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib retitled this revision from to Avoid EINTR when debugging..
kib updated this object.
kib edited the test plan for this revision. (Show Details)
kib added reviewers: jhb, avg.
kib set the repository for this revision to rS FreeBSD src repository - subversion.

I have no issue w/ the kern_event.c change. I am have not reviewed anything else.

sys/kern/kern_event.c
1531

I have no issue w/ this change.

Downside of this is that timeouts of the affected calls (kqueue/select/poll/nanosleep) are reset after a debug interrupt. If debug interrupts occur more often than the timeout, the calls will never time out. This is probably less harmful than the current [EINTR] but still a bug.

This can probably be fixed for the most part by storing the original wake up time (absolute sbintime) in struct thread and removing the record when resuming at a different location (in addition to when it is used).

System calls that take an absolute time or usable scratch space to store the remaining time do not have this problem.

sys/kern/sys_process.c
1046

This hunk seems unrelated to the rest of this patch.

In D3654#84710, @jilles wrote:

Downside of this is that timeouts of the affected calls (kqueue/select/poll/nanosleep) are reset after a debug interrupt. If debug interrupts occur more often than the timeout, the calls will never time out. This is probably less harmful than the current [EINTR] but still a bug.

This can probably be fixed for the most part by storing the original wake up time (absolute sbintime) in struct thread and removing the record when resuming at a different location (in addition to when it is used).

System calls that take an absolute time or usable scratch space to store the remaining time do not have this problem.

Yes, the restart problem is there. So, do you agree with having something along this lines (with or without the handling of timeout spent time) ?

sys/kern/sys_process.c
1046

Definitely, thanks for noting.

In D3654#85162, @kib wrote:

Yes, the restart problem is there. So, do you agree with having something along this lines (with or without the handling of timeout spent time) ?

I like the idea of making debugging more transparent to the debugged process but I'm a bit wary of introducing behaviours that may cause other unexpected results. It also has a bit more tentacles into general kernel code than I'd like, but I'm not sure that can be fixed.