Skip to content

(master) test: fail when a child terminates abnormally - #3777

Merged
metux merged 1 commit into
masterfrom
pr/master-test-fail-when-a-child-terminates-abnormally-_2026-10-01_15-15-29
Oct 1, 2026
Merged

metux merged 1 commit into
masterfrom
pr/master-test-fail-when-a-child-terminates-abnormally-_2026-10-01_15-15-29

Conversation

@metux

@metux metux commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

When a later test child is killed by a signal, exit_code may still contain zero from the preceding child. Return EXIT_FAILURE explicitly so Meson cannot report a false success.

Part-of: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2293
(cherry picked from commit 495ea74)
(cherry picked from commit 21e4929c355df7f525d0d0299781ccb6daa83780)
(cherry picked from commit d9abd11)

@metux metux self-assigned this Oct 1, 2026
@metux
metux requested a review from a team October 1, 2026 13:16
metux pushed a commit that referenced this pull request Oct 1, 2026
When a later test child is killed by a signal, exit_code may still contain zero from the preceding child. Return EXIT_FAILURE explicitly so Meson cannot report a false success.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2293>
(cherry picked from commit 495ea74)
(cherry picked from commit 21e4929c355df7f525d0d0299781ccb6daa83780)
(cherry picked from commit d9abd11)
PR: #3777
When a later test child is killed by a signal, exit_code may still contain zero from the preceding child. Return EXIT_FAILURE explicitly so Meson cannot report a false success.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2293>
(cherry picked from commit 495ea74)
(cherry picked from commit 21e4929c355df7f525d0d0299781ccb6daa83780)
(cherry picked from commit d9abd11)
Signed-off-by: Lukáš Lipinský <18076-Mr-Tao@users.noreply.gitlab.freedesktop.org>
@metux
metux force-pushed the pr/master-test-fail-when-a-child-terminates-abnormally-_2026-10-01_15-15-29 branch from 5d47240 to 10da3c7 Compare October 1, 2026 13:32
metux pushed a commit that referenced this pull request Oct 1, 2026
When a later test child is killed by a signal, exit_code may still contain zero from the preceding child. Return EXIT_FAILURE explicitly so Meson cannot report a false success.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2293>
(cherry picked from commit 495ea74)
(cherry picked from commit 21e4929c355df7f525d0d0299781ccb6daa83780)
(cherry picked from commit d9abd11)
PR: #3777
metux pushed a commit that referenced this pull request Oct 1, 2026
When a later test child is killed by a signal, exit_code may still contain zero from the preceding child. Return EXIT_FAILURE explicitly so Meson cannot report a false success.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2293>
(cherry picked from commit 495ea74)
(cherry picked from commit 21e4929c355df7f525d0d0299781ccb6daa83780)
(cherry picked from commit d9abd11)
PR: #3777
@metux

metux commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Automated review — generated by Starfleet ship Enterprise (model: heavy-model) on behalf of @metux. Not a human review.

Review: pass — and this one hides crashes silently, so it is worth taking

The one-line change is correct. The reason it matters is worth writing down,
because the current failure mode is quiet.

The bug

cpid = fork();
if (cpid) {
    waitpid(cpid, &csts, 0);
    if (!WIFEXITED(csts))
        goto child_failed;              /* child died on a signal */
    exit_code = WEXITSTATUS(csts);     /* <-- jumped over */
    if (exit_code != 0) {
child_failed:
        printf(" FAIL\n");
        exit(exit_code);                /* <-- uses the stale/initial value */
    }
}

exit_code is declared at function scope as int exit_code = -1; and the loop
walks a whole suite (while (*func)). So the value used at child_failed depends
on what happened earlier:

  • First test in the suite dies on a signal — exit_code is still its
    initialiser -1, so exit(-1) yields status 255. Reported as failure, but by
    accident, and with a misleading status.
  • Any later test dies on a signal, after an earlier test passed — exit_code
    is still 0 from that earlier test. exit(0) → the harness process exits
    successfully while having printed FAIL.

The second case is the one that matters: meson test / ctest keys off the exit
status, so a segfaulting test binary is reported as a pass. The FAIL on
stdout is the only trace, and CI does not read it. Every lane that runs these
suites is currently blind to child crashes.

exit(EXIT_FAILURE) makes every failure path deterministically non-zero, which
is exactly the invariant the harness needs. Correct and minimal.

Advisory (non-blocking): the two failure modes are now indistinguishable

After the change, "child was killed by SIGSEGV" and "child returned 1" produce the
same output and the same status. WTERMSIG(csts) in the child_failed path
would cost one line and make a crashing test diagnosable from CI output alone.
Worth doing while the context is fresh; not worth blocking on.

Expectation-setting for whoever merges this

Lanes may turn red after this lands, and that would be the fix working rather
than a regression: any crash previously reported as green becomes visible. Worth
knowing before the first red run is misread as breakage caused by this PR.

Rule 2 — backport assessment

Not a security or product-correctness backport candidate, and I want to be precise
about why rather than mechanical: tests-common.c is not linked into the server or
any shipped artifact, so no release user is affected by the bug itself.

It is nevertheless worth backporting to release/25.2, release/25.1,
release/25.0 — the release branches run these same suites, and on them the bug
currently suppresses crash detection too. The value is test-suite integrity, not
user-facing risk. Maintainer decides; no backport opened here.

Rule 3 — driver ABI

No impact, verified by construction rather than by grep alone: tests-common.c
appears in the unit-test source list in test/meson.build:202, where each entry
becomes its own test executable. It is not part of the server, of libxserver, or
of any module a driver could link against, and the diff contains 0 _X_EXPORT
occurrences.

@metux metux added the bot-review-passed Automated bot review found no blocking issues label Oct 1, 2026
@metux
metux merged commit b799d88 into master Oct 1, 2026
@metux
metux deleted the pr/master-test-fail-when-a-child-terminates-abnormally-_2026-10-01_15-15-29 branch October 1, 2026 16:53
@metux

metux commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Backport-Übersicht — Merge-Status live

Die Referenzen stehen als Task-Liste, damit GitHub jede beim Rendern zu einem
Eintrag mit Titel und aktuellem Status aufklappt. Es ist ausdrücklich keine
eigene Status-Spalte
gepflegt: die altert per Definition.

Auflösung: GH- allein rendert nur als Kurzlink. Erst in einer Liste klappt
GitHub Titel und State aus (GitHub-Doku, "Autolinked references and URLs").

metux pushed a commit that referenced this pull request Oct 5, 2026
When a later test child is killed by a signal, exit_code may still contain zero from the preceding child. Return EXIT_FAILURE explicitly so Meson cannot report a false success.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2293>
(cherry picked from commit 495ea74)
(cherry picked from commit 21e4929c355df7f525d0d0299781ccb6daa83780)
(cherry picked from commit d9abd11)
PR: #3777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-passed Automated bot review found no blocking issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant