Skip to content

always capture a stack trace when a test process crashes - #18517

Merged
kevinushey merged 1 commit into
mainfrom
developer/test-harness-segfault-backtraces
Aug 11, 2026
Merged

kevinushey merged 1 commit into
mainfrom
developer/test-harness-segfault-backtraces

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Motivation

On a recent Jenkins c++-unit-tests run (PR-18509 build 2), the rsession gtest scope segfaulted ~250ms into process startup with no diagnostics whatsoever -- just the shell's Segmentation fault (core dumped) line. libSegFault was preloaded, but:

  • libSegFault's handler cannot run on an exhausted stack, so stack-overflow segfaults die silently unless the handler is installed on an alternate stack (SEGFAULT_USE_ALTSTACK);
  • libSegFault was removed from glibc entirely in 2.35+, so newer builders get no crash diagnostics at all (rstudio-tests already warns Could not find libSegFault.so there).

Changes

rstudio-tests.in (Linux diagnostics; macOS and Windows unchanged):

  • set SEGFAULT_USE_ALTSTACK=1 so libSegFault can report stack-overflow crashes;
  • raise the core ulimit for the test process, and on death-by-signal (exit code > 128) locate the fresh core dump and print a gdb backtrace from it (capped at 100 frames per thread, since a stack-overflow core otherwise dumps thousands). Handles a relative core_pattern (cwd), an absolute one, apport's coredump directory, and systemd-coredump via coredumpctl;
  • delete examined cores afterwards so reused CI workspaces don't accumulate them.

A timestamp marker ensures only cores produced by the current run are examined.

Testing

Verified in ubuntu:20.04 (libSegFault present) and ubuntu:24.04 (glibc 2.39, no libSegFault) containers, using the rendered harness with null-dereference and stack-overflow crash binaries substituted for the core test suite:

  • ubuntu:24.04: both crashes produce a gdb backtrace from the core with correct source frames;
  • ubuntu:20.04: both crashes produce a libSegFault backtrace, plus the gdb core backtrace;
  • control: the stack-overflow crasher under libSegFault without SEGFAULT_USE_ALTSTACK reproduces the silent CI failure exactly (only the shell's exit-status line, no backtrace).

Also bash -n and shellcheck clean.

Developer-only tooling change; no NEWS entry.

The rsession gtest scope segfaulted at startup on a PR-18509 CI run with
no diagnostics at all: libSegFault was preloaded, but its handler cannot
run on an exhausted stack, so a stack-overflow crash dies with nothing
but the shell's exit status. libSegFault is also gone from glibc 2.35+.

Harden the test harness:

- set SEGFAULT_USE_ALTSTACK so libSegFault installs its handler on an
  alternate stack and can report stack-overflow crashes
- raise the core ulimit, and on death-by-signal locate the core dump
  (cwd, absolute core_pattern target, or apport/systemd-coredump) and
  print a gdb backtrace from it, capped at 100 frames per thread
- clean up examined cores so reused CI workspaces don't accumulate them

Verified in ubuntu:20.04 (libSegFault present) and ubuntu:24.04 (no
libSegFault; gdb-on-core fallback) containers with null-dereference and
stack-overflow crashers: every scenario now yields a usable backtrace,
and the stack-overflow-without-altstack control reproduces the silent
CI failure.
@kevinushey kevinushey added this to the 2026.09 (Autumn Hawkbit) milestone Aug 11, 2026
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
2077 0 384 6
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 8 0
✅ desktop-linux 516 0 89 2
✅ desktop-macos 510 0 95 3
✅ desktop-windows 523 0 90 0
✅ server-linux 504 0 94 1
✅ setup 22 0 8 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 3d5083f623e463a795956b18d61bd55d7b14a793 - Run #533

@kevinushey
kevinushey merged commit 1383068 into main Aug 11, 2026
27 checks passed
@kevinushey
kevinushey deleted the developer/test-harness-segfault-backtraces branch August 11, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant