Skip to content

timeout: don't dump core when re-raising the child's signal - #15157

Open
TanbirRamim wants to merge 2 commits into
uutils:mainfrom
TanbirRamim:timeout-no-core-dump
Open

TanbirRamim wants to merge 2 commits into
uutils:mainfrom
TanbirRamim:timeout-no-core-dump

Conversation

@TanbirRamim

Copy link
Copy Markdown
Contributor

When the child dies from something like SIGSEGV, timeout kills itself with the same signal to pass the status on, and that made timeout dump core too (so apport blamed timeout for the crash). Now it turns off core dumps first like GNU does (prctl PR_SET_DUMPABLE, falling back to RLIMIT_CORE=0) and only re-raises if that worked.

Added a test that runs it under ulimit -c unlimited and checks timeout's own status isn't a core dump. It fails on Linux without the fix. I didn't add the "monitored command dumped core" message, can do that in a follow-up if wanted.

Fixes #15144

Copilot AI balanced review requested due to automatic review settings October 7, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/uu/timeout/src/platform/unix.rs Outdated
fn disable_core_dumps() -> bool {
#[cfg(any(target_os = "linux", target_os = "android"))]
// SAFETY: PR_SET_DUMPABLE only takes an integer argument.
if unsafe { libc::prctl(libc::PR_SET_DUMPABLE, 0) } == 0 {

@oech3 oech3 Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you remove unsafe by rustix?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, it uses rustix now (set_dumpable_behavior + setrlimit), no unsafe left.

Comment thread tests/by-util/test_timeout.rs Outdated
/// When the child dumps core, timeout re-raises its signal without dumping
/// core itself.
#[test]
#[cfg(any(target_os = "linux", target_os = "macos"))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

on macOS the child sh will write a real core into /cores, which can be several GB on the runner. Could we keep this test linux only?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, made it Linux only.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 03:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.04 MB (-308 KB, -0.19%)

Significant per-binary changes:
  date     2.61 MB ->    2.30 MB  (-316 KB, -11.81%)

@codspeed

codspeed Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 10 untouched benchmarks
⏩ 462 skipped benchmarks1


Comparing TanbirRamim:timeout-no-core-dump (9dc7673) with main (ff0c589)2

Open in CodSpeed

Footnotes

  1. 462 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (732b9c5) during the generation of this report, so ff0c589 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@sylvestre
sylvestre force-pushed the timeout-no-core-dump branch from df98adb to 9dc7673 Compare October 25, 2026 09:54
Copilot AI balanced review requested due to automatic review settings October 25, 2026 09:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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.

timeout: re-raising the child's signal dumps core in timeout itself (GNU disables core dumps first)

4 participants