Commit 366b569
authored
Make
On cancellation, the test's teardown sent the child `SIGINT`, escalating
to `SIGKILL` after 100ms; the `INT` trap was meant to kill the runaway
grandchild and `exit 0`, and the child otherwise blocked in
`wait "$child_pid"`. It failed intermittently in two ways, both from
trapping an asynchronous signal around a blocking `wait`.
First, `signaled(11)`: bash interrupted the `wait` for `SIGINT` via
`siglongjmp`, and on Darwin's system bash (3.2, arm64e) that `longjmp`
occasionally failed pointer authentication and crashed the child with
`SIGSEGV`.
Second, `signaled(9)`: if the signal landed after bash last checked
pending traps, but before it blocked in `wait`, the trap was recorded
but never run. A `wait` on a child that never exited offers no further
safe point, so the child lived until teardown escalated to `SIGKILL`.
Send `SIGTERM` instead. Its trap runs at a deferred safe point rather
than `longjmp`-ing out of the handler, so the crash cannot occur. Poll
with `kill -0`/`sleep` rather than blocking in `wait`, so a deferred
trap runs within one short interval; also widen the grace period so it
comfortably exceeds that interval and the trap is serviced before
escalation.testRunawayProcess() deterministic (#295)1 parent d15a7a0 commit 366b569
1 file changed
Lines changed: 17 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
477 | | - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
478 | 482 | | |
479 | 483 | | |
480 | 484 | | |
| |||
486 | 490 | | |
487 | 491 | | |
488 | 492 | | |
489 | | - | |
490 | | - | |
| 493 | + | |
| 494 | + | |
491 | 495 | | |
492 | 496 | | |
493 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
494 | 505 | | |
495 | 506 | | |
496 | 507 | | |
| |||
499 | 510 | | |
500 | 511 | | |
501 | 512 | | |
502 | | - | |
| 513 | + | |
503 | 514 | | |
504 | 515 | | |
505 | 516 | | |
| |||
0 commit comments