Skip to content

ci(desktop): surface crash reports for signal-killed Swift suites (#11573) - #11589

Merged
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-11573-swift-suite-crash-reports
Aug 14, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
watchdog/issue-11573-swift-suite-crash-reports

Conversation

@kodjima33

@kodjima33 kodjima33 commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Bug

Desktop Swift Static & Test Contracts has been red on main since 15a51fb985, and three of its seven failing suites die with error: Exited with unexpected signal code 11 (#11573): AgentPillLifecycleTests, ChatTimelineContinuityTests, MarkdownNestedScrollTests.

That one line is all SwiftPM emits for a signal death — no frames, no exception type, no faulting thread. The system crash report that does carry the backtrace is written to the runner's ~/Library/Logs/DiagnosticReports and discarded with the machine when the job ends. None of the three suites reproduce on either available maintainer machine (macOS 26.4 / Xcode 26.4 vs CI's macOS 15 / Xcode 16.4), so CI is the only environment that can produce the evidence — and CI was throwing it away. The crashers have been undiagnosable for two days for exactly this reason, and #11573 asks for this capture by name.

Fix

desktop/macos/scripts/swift-test-suites.sh:

  • stamps a marker file immediately before suite execution (after the prebuild, so prebuild-era reports are not attributed to a suite),
  • when a failing suite's log carries Exited with unexpected signal, records it,
  • after the failure summary, prints Signal-killed Swift suites: … and cats every .ips written after the marker (capped, OMI_SWIFT_TEST_CRASH_REPORT_LIMIT, default 6).

The report directory and cap are overridable (OMI_SWIFT_TEST_CRASH_REPORT_DIR) so the runner's own harness can drive this hermetically. The whole path is inert unless a suite dies on a signal; on a green lane it adds nothing and costs nothing.

What I tested

  • Regression test — desktop/macos/tests/test-swift-test-suites.sh gains a signal-death fixture. On the unmodified runner it fails (runner did not name the signal-killed suite); with the change it passes. It asserts both directions: a report written during the run is printed, and a report predating the run is not attributed to it (No crash reports newer than this run), because sending the next reader after the wrong backtrace is worse than printing nothing.

    $ bash desktop/macos/tests/test-swift-test-suites.sh
    swift-test-suites tests passed
    $ git stash push -- desktop/macos/scripts/swift-test-suites.sh && bash desktop/macos/tests/test-swift-test-suites.sh
    FAIL: runner did not name the signal-killed suite
    
  • Real mechanism, not just the fixture — on macOS 26.4 a deliberate SIGSEGV process (exit=139) wrote ~/Library/Logs/DiagnosticReports/segv-2026-08-14-171402.ips; find -newer <marker> selected it, and the report carried EXC_BAD_ACCESS / SIGSEGV / KERN_INVALID_ADDRESS, the faulting thread, and symbolicated frames. That is precisely the payload Desktop Swift lane: 3 suites SIGSEGV on CI only (AgentPill, ChatTimelineContinuity, MarkdownNestedScroll) — the remaining blocker after #11563 #11573 is missing.

  • shellcheck -S warning clean on both files.

  • run_checks.py --lane local --skip-changelog: 13/13 pass. Changelog gate is satisfied by the no-changelog-needed label — this is CI diagnostics, nothing a user sees.

Note on the lane

The Desktop Swift lane is red on main independently of this change (7 pre-existing failing suites: the 3 crashers above plus GlassSurfaceReviewRegressionTests, ProactiveLaneClientTests, RewindSurfaceLayoutTests, ShellModalScrimDismissTests). This PR does not fix them — it makes the 3 crashers diagnosable. It is merged only if its lane run shows no failure beyond that known set.

Closes nothing; feeds #11573.

🤖 automated by the hourly desktop watchdog — tested and merged

Review in cubic

…1573)

A Swift suite killed by a signal leaves exactly one line in SwiftPM's log —
"error: Exited with unexpected signal code 11" — and no frames. On a hosted
runner the system crash report that does hold the backtrace is discarded with
the machine, so the three suites crashing only on CI (#11573) have been
undiagnosable from the Actions log alone for two days: AgentPillLifecycleTests,
ChatTimelineContinuityTests, MarkdownNestedScrollTests.

swift-test-suites.sh now stamps a marker before suite execution, and when a
failing suite's log carries a signal death it names the signal-killed suites
and prints every .ips written after that marker. The marker is what keeps a
pre-run report from being attributed to this run's crasher.

Verified:
- desktop/macos/tests/test-swift-test-suites.sh — new coverage fails on the
  unmodified runner ("runner did not name the signal-killed suite") and passes
  with it; asserts the fresh report is printed and a pre-run report is not.
- Real path on macOS 26.4: a deliberate SIGSEGV process (exit 139) writes
  ~/Library/Logs/DiagnosticReports/segv-*.ips, `find -newer <marker>` selects
  it, and the report carries EXC_BAD_ACCESS/SIGSEGV plus symbolicated frames.
- shellcheck -S warning: clean on both files.

Inert unless a suite dies on a signal; it only adds log output.
@kodjima33 kodjima33 added the no-changelog-needed Skip desktop changelog enforcement for internal-only changes label Aug 14, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 2 files

Confidence score: 3/5

  • In desktop/macos/scripts/swift-test-suites.sh (dump_crash_reports), the sort | head pipeline can trip pipefail (SIGPIPE) and abort diagnostics before crash output and the normal suite failure summary are shown, which can hide the real test failure signal in CI logs — switch to a limiting approach that doesn’t treat expected early pipe close as fatal.
  • In desktop/macos/scripts/swift-test-suites.sh, a nonnumeric OMI_SWIFT_TEST_CRASH_REPORT_LIMIT makes head fail and causes the diagnostics path itself to exit nonzero, again replacing useful suite-failure context with a tooling error — validate/sanitize the env var and fall back to a safe default.
  • In desktop/macos/scripts/swift-test-suites.sh, relying on marker-time -newer plus lexical filename sorting can miss late-written .ips files and select the wrong subset when many reports exist, so the captured crash reports may be incomplete or misleading — use a collection window and mtime-based ordering before applying the cap.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="desktop/macos/scripts/swift-test-suites.sh">

<violation number="1" location="desktop/macos/scripts/swift-test-suites.sh:38">
P2: When `OMI_SWIFT_TEST_CRASH_REPORT_LIMIT` is nonnumeric, `head` rejects it and the `pipefail` assignment exits nonzero. The runner then aborts from diagnostics instead of preserving its normal suite failure summary; validate this override before running suites.</violation>

<violation number="2" location="desktop/macos/scripts/swift-test-suites.sh:52">
P2: The marker-based `-newer` filter assumes crash reports are written synchronously with process death, but macOS writes .ips files through the ReportCrash daemon asynchronously. The suite process dies on a signal and `dump_crash_reports` runs a few milliseconds later, so the very report this PR exists to surface can still be mid-write and be missed, printing "No crash reports newer than this run". Conversely, a crash earlier in the run (e.g. the prebuild `xcrun swift build`) has its .ips written a second or two later — after `crash_marker` was touched — and would be attributed to a suite crasher, the exact misattribution the marker comment says it prevents. This undermines the stated design intent ("the prebuild and anything the runner did earlier must not be attributed to a crasher").</violation>

<violation number="3" location="desktop/macos/scripts/swift-test-suites.sh:53">
P2: When enough fresh reports exceed the cap, `head` closes the pipe and `sort` exits with SIGPIPE under `pipefail`. `dump_crash_reports` then aborts before printing reports or the normal failure summary; use a limiting consumer that reads the full sorted stream.</violation>

<violation number="4" location="desktop/macos/scripts/swift-test-suites.sh:53">
P3: The `sort` orders reports lexically by full path (filename), not by modification time, then `head -n "$CRASH_REPORT_LIMIT"` keeps the first `CRASH_REPORT_LIMIT` alphabetically. When a run produces more reports than the cap, the newest backtrace can be dropped in favor of an arbitrary (alphabetically first) file, which defeats the diagnostic ordering for a burst of crashers.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

# so a crasher that only reproduces on CI is undebuggable from the log alone
# (#11573). Print the reports this run produced next to the failing suites.
CRASH_REPORT_DIR="${OMI_SWIFT_TEST_CRASH_REPORT_DIR:-$HOME/Library/Logs/DiagnosticReports}"
CRASH_REPORT_LIMIT="${OMI_SWIFT_TEST_CRASH_REPORT_LIMIT:-6}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When OMI_SWIFT_TEST_CRASH_REPORT_LIMIT is nonnumeric, head rejects it and the pipefail assignment exits nonzero. The runner then aborts from diagnostics instead of preserving its normal suite failure summary; validate this override before running suites.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/scripts/swift-test-suites.sh, line 38:

<comment>When `OMI_SWIFT_TEST_CRASH_REPORT_LIMIT` is nonnumeric, `head` rejects it and the `pipefail` assignment exits nonzero. The runner then aborts from diagnostics instead of preserving its normal suite failure summary; validate this override before running suites.</comment>

<file context>
@@ -29,12 +29,40 @@ PREBUILD="${OMI_SWIFT_TEST_PREBUILD:-1}"
+# so a crasher that only reproduces on CI is undebuggable from the log alone
+# (#11573). Print the reports this run produced next to the failing suites.
+CRASH_REPORT_DIR="${OMI_SWIFT_TEST_CRASH_REPORT_DIR:-$HOME/Library/Logs/DiagnosticReports}"
+CRASH_REPORT_LIMIT="${OMI_SWIFT_TEST_CRASH_REPORT_LIMIT:-6}"
 
 fail() {
</file context>
Suggested change
CRASH_REPORT_LIMIT="${OMI_SWIFT_TEST_CRASH_REPORT_LIMIT:-6}"
CRASH_REPORT_LIMIT="${OMI_SWIFT_TEST_CRASH_REPORT_LIMIT:-6}"
if ! [[ "$CRASH_REPORT_LIMIT" =~ ^[0-9]+$ ]]; then
echo "FAIL: OMI_SWIFT_TEST_CRASH_REPORT_LIMIT must be a non-negative integer, got '$CRASH_REPORT_LIMIT'" >&2
exit 1
fi

fi
local reports
reports="$(find "$CRASH_REPORT_DIR" -maxdepth 1 -type f -name '*.ips' -newer "$marker" 2>/dev/null \
| sort | head -n "$CRASH_REPORT_LIMIT")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When enough fresh reports exceed the cap, head closes the pipe and sort exits with SIGPIPE under pipefail. dump_crash_reports then aborts before printing reports or the normal failure summary; use a limiting consumer that reads the full sorted stream.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/scripts/swift-test-suites.sh, line 53:

<comment>When enough fresh reports exceed the cap, `head` closes the pipe and `sort` exits with SIGPIPE under `pipefail`. `dump_crash_reports` then aborts before printing reports or the normal failure summary; use a limiting consumer that reads the full sorted stream.</comment>

<file context>
@@ -29,12 +29,40 @@ PREBUILD="${OMI_SWIFT_TEST_PREBUILD:-1}"
+  fi
+  local reports
+  reports="$(find "$CRASH_REPORT_DIR" -maxdepth 1 -type f -name '*.ips' -newer "$marker" 2>/dev/null \
+    | sort | head -n "$CRASH_REPORT_LIMIT")"
+  if [ -z "$reports" ]; then
+    echo "No crash reports newer than this run in $CRASH_REPORT_DIR."
</file context>

return
fi
local reports
reports="$(find "$CRASH_REPORT_DIR" -maxdepth 1 -type f -name '*.ips' -newer "$marker" 2>/dev/null \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The marker-based -newer filter assumes crash reports are written synchronously with process death, but macOS writes .ips files through the ReportCrash daemon asynchronously. The suite process dies on a signal and dump_crash_reports runs a few milliseconds later, so the very report this PR exists to surface can still be mid-write and be missed, printing "No crash reports newer than this run". Conversely, a crash earlier in the run (e.g. the prebuild xcrun swift build) has its .ips written a second or two later — after crash_marker was touched — and would be attributed to a suite crasher, the exact misattribution the marker comment says it prevents. This undermines the stated design intent ("the prebuild and anything the runner did earlier must not be attributed to a crasher").

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/scripts/swift-test-suites.sh, line 52:

<comment>The marker-based `-newer` filter assumes crash reports are written synchronously with process death, but macOS writes .ips files through the ReportCrash daemon asynchronously. The suite process dies on a signal and `dump_crash_reports` runs a few milliseconds later, so the very report this PR exists to surface can still be mid-write and be missed, printing "No crash reports newer than this run". Conversely, a crash earlier in the run (e.g. the prebuild `xcrun swift build`) has its .ips written a second or two later — after `crash_marker` was touched — and would be attributed to a suite crasher, the exact misattribution the marker comment says it prevents. This undermines the stated design intent ("the prebuild and anything the runner did earlier must not be attributed to a crasher").</comment>

<file context>
@@ -29,12 +29,40 @@ PREBUILD="${OMI_SWIFT_TEST_PREBUILD:-1}"
+    return
+  fi
+  local reports
+  reports="$(find "$CRASH_REPORT_DIR" -maxdepth 1 -type f -name '*.ips' -newer "$marker" 2>/dev/null \
+    | sort | head -n "$CRASH_REPORT_LIMIT")"
+  if [ -z "$reports" ]; then
</file context>

fi
local reports
reports="$(find "$CRASH_REPORT_DIR" -maxdepth 1 -type f -name '*.ips' -newer "$marker" 2>/dev/null \
| sort | head -n "$CRASH_REPORT_LIMIT")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The sort orders reports lexically by full path (filename), not by modification time, then head -n "$CRASH_REPORT_LIMIT" keeps the first CRASH_REPORT_LIMIT alphabetically. When a run produces more reports than the cap, the newest backtrace can be dropped in favor of an arbitrary (alphabetically first) file, which defeats the diagnostic ordering for a burst of crashers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/scripts/swift-test-suites.sh, line 53:

<comment>The `sort` orders reports lexically by full path (filename), not by modification time, then `head -n "$CRASH_REPORT_LIMIT"` keeps the first `CRASH_REPORT_LIMIT` alphabetically. When a run produces more reports than the cap, the newest backtrace can be dropped in favor of an arbitrary (alphabetically first) file, which defeats the diagnostic ordering for a burst of crashers.</comment>

<file context>
@@ -29,12 +29,40 @@ PREBUILD="${OMI_SWIFT_TEST_PREBUILD:-1}"
+  fi
+  local reports
+  reports="$(find "$CRASH_REPORT_DIR" -maxdepth 1 -type f -name '*.ips' -newer "$marker" 2>/dev/null \
+    | sort | head -n "$CRASH_REPORT_LIMIT")"
+  if [ -z "$reports" ]; then
+    echo "No crash reports newer than this run in $CRASH_REPORT_DIR."
</file context>

@kodjima33
kodjima33 merged commit 9a4213a into main Aug 14, 2026
32 of 35 checks passed
@kodjima33
kodjima33 deleted the watchdog/issue-11573-swift-suite-crash-reports branch August 14, 2026 22:23
kodjima33 added a commit that referenced this pull request Aug 15, 2026
…#11596)

Three Swift suites have died with SIGSEGV on the macos-15 CI runner since
2026-08-14, leaving the desktop lane red on every run that executes desktop
tests: AgentPillLifecycleTests, ChatTimelineContinuityTests,
MarkdownNestedScrollTests.

The crash report surfaced by #11589 names the cause. It is a stack overflow,
not a bad pointer: the faulting address sits 80 bytes below thread 0's stack
limit inside the guard region, and the backtrace is 511 frames of one repeating
unit --

  OmiMarkdownContent -> _ConditionalContent -> OmiMarkdownCitationContent
    -> _ConditionalContent -> OmiMarkdownContent -> ...

all of it `View._viewListCount(inputs:)`. That is a *static* walk: SwiftUI
resolves it from view types alone and never evaluates a body, so the cycle is
in the type graph, not in any value. `OmiMarkdownContent.body` reaches
`OmiMarkdownCitationContent` through both `textView` and `OmiMarkdownTableView`,
and the citation view's mask-failure fallback named `OmiMarkdownContent` --
closing two cycles on one back-edge. The fallback almost never executes at
runtime, which is why this looked value-dependent for two days; the static walk
recurses regardless of whether that branch is ever taken.

Erasing that one back-edge with `AnyView` terminates the walk (`AnyView`
resolves its count dynamically) and leaves the graph acyclic.

The cycle was closed by 00cc9ed "feat(desktop): add clickable source
citations (#11519)" (David Zhang, 2026-08-13), which introduced
`OmiMarkdownCitationContent` and its fallback.

Not CI-only: the production transcript hosts the same tree
(ChatMessagesView.scrollContent -> ScrollView -> VStack -> ChatBubble ->
OmiMarkdown), so a macOS 15 user on a build carrying #11519 hits the same
recursion. Changelog entry added.

Verified:
- desktop/macos/scripts/swift-test-suites.sh over the three crashing suites
  plus OmiMarkdownCitationInteractionTests and OmiMarkdownLineSpacingTests.
- New regression test measures a cited answer inside a ScrollView/LazyVStack
  host -- the container that forces the static count. Pre-fix that shape is
  what kills the process on macOS 15; it cannot fail an assertion, so the
  suite's survival on the macos-15 runner is the assertion.
- The macos-15 CI lane is the authority here: the crash does not reproduce on
  macOS 26, so lane-green on this PR is the proof.

Failure-Class: new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Skip desktop changelog enforcement for internal-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant