It seems that the test case is timing out periodically on i386. Example: https://ci.freebsd.org/job/FreeBSD-head-i386-test/5228/testReport/junit/sys.kern/pdeathsig/signal_delivered_ptrace/.
Two more after the report: https://ci.freebsd.org/job/FreeBSD-head-i386-test/5992/testReport/sys.kern/pdeathsig/signal_delivered_ptrace/ https://ci.freebsd.org/job/FreeBSD-head-i386-test/5975/testReport/sys.kern/pdeathsig/signal_delivered_ptrace/ This also happened once on amd64: https://ci.freebsd.org/job/FreeBSD-head-amd64-test/8861/testReport/junit/sys.kern/pdeathsig/signal_delivered_ptrace/
At least one issue I noted is that ptrace(PT_DETACH) is called without the target process C being stopped. This results in failure of detaching, i.e. the the debugger process D still has C attached, and then D exits. If D exits before C executes its actions, C is killed because its debugger was killed. Then, the wait for a pipe read in the process A becomes infinite, since the write end of the pipe exists in the process A as well. Try the patch attached and report if it helped.
Created attachment 206439 [details] Wait for the process C termination or stop, in the later case detach.
> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=206439 I have tested this patch but it still timed out sometimes. Run this case in an infinite loop it usually failed because of timeout in 5 mins. Is there any other information we can provide while running this?
(In reply to Li-Wen Hsu from comment #4) I need the ktrace -di/kdump of the failed run.
(In reply to Konstantin Belousov from comment #5) Please check if these are useful: https://people.freebsd.org/~lwhsu/bug237657/
Created attachment 206610 [details] Fix two races in the ptrace process, one at attach, another at detach. I see one more race, now B might exit before C ever set PROC_PDEATHSIG_CTL. Try the updated patch.
With new patch this has been running in a while loop for 8 hours without error. I think it is fine.
A commit references this bug: Author: kib Date: Mon Aug 19 09:29:27 UTC 2019 New revision: 351210 URL: https://svnweb.freebsd.org/changeset/base/351210 Log: sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach ptrace(PT_DETACH) requires stopped debuggee, otherwise it fails. When the call fails, the C process is left as debuggee of the process D, and might be killed too early if process D exits occurs fast enough. Since pipes are not closed in the forked children, this resulted in the test hanging, since no write occured from C to wake A. PR: 237657 Reported and tested by: lwhsu Sponsored by: The FreeBSD Foundation MFC after: 1 week Changes: head/tests/sys/kern/pdeathsig.c
A commit references this bug: Author: kib Date: Mon Aug 19 09:33:09 UTC 2019 New revision: 351211 URL: https://svnweb.freebsd.org/changeset/base/351211 Log: sys.kern.pdeathsig.signal_delivered_ptrace: fix startup. Inform D that C executed procctl(PROC_PDEATHSIG_CTL). Otherwise D might allow B to exit before C is set up to receive a signal on the parent exit. In this case, C waits forever for the signal and test hangs. PR: 237657 Reported and tested by: lwhsu Sponsored by: The FreeBSD Foundation MFC after: 1 week Changes: head/tests/sys/kern/pdeathsig.c
A commit references this bug: Author: kib Date: Mon Aug 26 08:06:19 UTC 2019 New revision: 351503 URL: https://svnweb.freebsd.org/changeset/base/351503 Log: MFC r351210: sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach PR: 237657 Changes: _U stable/12/ stable/12/tests/sys/kern/pdeathsig.c
A commit references this bug: Author: kib Date: Mon Aug 26 08:07:10 UTC 2019 New revision: 351504 URL: https://svnweb.freebsd.org/changeset/base/351504 Log: MFC r351211: sys.kern.pdeathsig.signal_delivered_ptrace: fix startup. PR: 237657 Changes: _U stable/12/ stable/12/tests/sys/kern/pdeathsig.c
A commit references this bug: Author: kib Date: Mon Aug 26 08:07:47 UTC 2019 New revision: 351505 URL: https://svnweb.freebsd.org/changeset/base/351505 Log: MFC r351210: sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach PR: 237657 Changes: _U stable/11/ stable/11/tests/sys/kern/pdeathsig.c
A commit references this bug: Author: kib Date: Mon Aug 26 08:08:16 UTC 2019 New revision: 351506 URL: https://svnweb.freebsd.org/changeset/base/351506 Log: MFC r351211: sys.kern.pdeathsig.signal_delivered_ptrace: fix startup. PR: 237657 Changes: _U stable/11/ stable/11/tests/sys/kern/pdeathsig.c