Skip to content

uucore: unblock realtime signals in unblock_signal - #16409

Open
aozmekik wants to merge 1 commit into
uutils:mainfrom
aozmekik:timeout-realtime-signal-unblock
Open

aozmekik wants to merge 1 commit into
uutils:mainfrom
aozmekik:timeout-realtime-signal-unblock

Conversation

@aozmekik

Copy link
Copy Markdown

Fixes #16407.

unblock_signal() converted the signal to nix's Signal with unwrap_unchecked(), but nix has no realtime signals, so when timeout's child died from one of them this was undefined behaviour (a debug build aborts). This builds the set with sigemptyset/sigaddset on the raw number instead, the way env already does.

With a debug build on Linux, timeout 10 sh -c 'kill -37 $$' used to abort with exit 134, and now exits with 165 (128 + 37), like SIGTERM gives 143. The new test fails on main (killed by SIGABRT instead of signal 37) and passes here. The timeout tests pass on Linux and macOS, and clippy -D warnings is clean for uucore.

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for picking this up!
The Style/lint job is red, probably cspell flagging sigemptyset/sigaddset (see inline).

@aozmekik
aozmekik force-pushed the timeout-realtime-signal-unblock branch from ee35925 to 5eab7ac Compare November 14, 2026 07:12
@codspeed

codspeed Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 5.72%

1 warning, 1 note

⚠️ 126 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

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 412 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation socket_addrs_direct[100000] 105.3 µs 133.1 µs -20.92%
❌ CPU Simulation hostname_ip_lookup[100000] 546.9 µs 577.2 µs -5.25%
⚡ Memory cp_recursive_deep_tree[(120, 4)] 789 KB 705.4 KB +11.86%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing aozmekik:timeout-realtime-signal-unblock (7314b5b) with main (887b9e6)2

Open in CodSpeed

Footnotes

  1. 70 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 (00b34f8) during the generation of this report, so 887b9e6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@aozmekik
aozmekik force-pushed the timeout-realtime-signal-unblock branch from 5eab7ac to 37a99bd Compare November 14, 2026 15:12
@sylvestre

Copy link
Copy Markdown
Contributor

@codspeedbot explain why performance improved

@codspeed

codspeed Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

@codspeedbot explain why performance improved

The +4.31% on du_wide_tree[(5000, 500)] doesn't come from this PR. It's noise.

Why the PR can't be the cause

  • The PR only changes unblock_signal() in src/uucore/src/lib/features/process/unix.rs, plus a timeout test. Between the base commit (ab90d65) and the head (5eab7ac), the other changed files are a workflow and util/fetch-gnu.sh. Nothing under src/uu/du changed.
  • That code sits behind uucore's process feature. uu_du doesn't turn that feature on, and the benchmark CI builds each util on its own (cargo codspeed build -p uu_du). So the new code isn't even compiled into the du benchmark binary.
  • This PR's previous commit (ee35925) has the same du code, and it measured 15.72 ms, the same as the base (15.67 ms). Only the latest run came in at 15.02 ms.

Where the 0.65 ms went
In the differential flamegraph, the du code itself didn't change: safe_du self time is 570.8 → 570.2 µs and copy_nonoverlapping is flat. Nearly all the gain is inside glibc's allocator, along the Path::join → realloc path:

  • _int_malloc: 1.8 → 1.2 ms
  • _int_realloc: 3.1 → 2.6 ms
  • free / chunk merging: a few percent less

Call counts are the same in both runs. The program did the same work, and only glibc's internal allocator work changed between the two runs.

The base and head also ran on different CI machines (AMD EPYC 9V74 → EPYC 7763), and CodSpeed flagged this benchmark for that. That kind of change can shift this benchmark's allocator cost by a few percent. Most of this benchmark's real cost is in system calls, which the CPU simulation leaves out, so small shifts in the allocator stand out.

You can ignore this change for the PR. Nothing needed to change, so I made no commits.

If you want to confirm it, comment @codspeedbot rerun the du benchmarks for this PR and I'll compare the two results.

Summary
  • Warming up the performance wizard...
  • Handling comment — Comment handling finished successfully

Learnings updated. See what CodSpeed remembers about this repository.

Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.

@sylvestre
sylvestre force-pushed the timeout-realtime-signal-unblock branch from 37a99bd to 27a4626 Compare November 16, 2026 03:28
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)

@aozmekik

Copy link
Copy Markdown
Author

Sorry for the late reply. The lint failure was the stty clippy error, which is fixed on main now, so I rebased. cspell was also warning on sigset/sigemptyset/sigaddset, I added them to the ignore line. The Tests job that is still red is the OpenBSD VM one, it was failing the same way on main when I checked.

nix's Signal has no realtime signals, so converting SIGRTMIN+n to it
failed and unwrap_unchecked() hit undefined behaviour when timeout
re-raised a realtime signal from its child.  Build the set from the raw
signal number with libc, as env already does.

Fixes uutils#16407
@sylvestre
sylvestre force-pushed the timeout-realtime-signal-unblock branch from 27a4626 to 7314b5b Compare November 28, 2026 09:23
set.add(unsafe { Signal::try_from(signal.as_raw()).unwrap_unchecked() });
// nix's Signal has no realtime signals, so build the set from the raw
// signal number.
let mut set = std::mem::MaybeUninit::<libc::sigset_t>::uninit();

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.

sigset_from_signal_value in env.rs does almost the same, could env use a shared uucore helper? fine as a follow-up :)

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: unwrap_unchecked on Err in uucore::process::unblock_signal when the child dies from a realtime signal

2 participants