8000 Skip stack overflow handler for panic=immediate-abort by Noratrieb · Pull Request #147090 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Conversation

Noratrieb
Copy link
Member
@Noratrieb Noratrieb commented Sep 27, 2025

std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately don't want nice messages, they want minimum binary size.

Therefore, skip the entire guard signal handler setup, which saves a lot of bytes.

I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo.

size reports significant savings:

   text	   data	    bss	    dec	    hex	filename
  15252	   1032	    104	  16388	   4004	tiny-before
   6881	    964	     48	   7893	   1ed5	tiny-after2

nm -U goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from 31k to 24k.

The impact on the error message is minimal, as the message was already
missing.

before:

fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort)

after:

fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error)

I didn't test the Windows part, but it likely also has savings.

@rustbot
Copy link
Collaborator
rustbot commented Sep 27, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-unix Operating system: Unix-like O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 27, 2025
@Noratrieb Noratrieb force-pushed the immediate-abort-stack-overflow branch 2 times, most recently from 8a58a60 to 3b88374 Compare September 27, 2025 12:12
std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately *don't* want nice messages, they want minimum binary size.

Therefore, skip the entire guard signal handler setup, which saves a lot of bytes.

I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo.

`size` reports significant savings:

```
   text	   data	    bss	    dec	    hex	filename
  15252	   1032	    104	  16388	   4004	tiny-before
   6881	    964	     48	   7893	   1ed5	tiny-after2
```

`nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`.

The impact on the error message is minimal, as the message was already
missing.

before:
```
fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort)
```

after:
```
fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error)
```
@Noratrieb Noratrieb force-pushed the immediate-abort-stack-overflow branch from 3b88374 to 660a348 Compare September 27, 2025 12:16
@Noratrieb Noratrieb changed the title Skip stackoverflow handler for panic=immediate-abort Skip stack overflow handler for panic=immediate-abort Sep 27, 2025
@joboet
Copy link
Member
joboet commented Sep 28, 2025

Makes sense!
@bors r+
r? joboet

@bors
Copy link
Collaborator
bors commented Sep 28, 2025

📌 Commit 660a348 has been approved by joboet

It is now in the queue for this repository.

@rustbot rustbot assigned joboet and unassigned ibraheemdev Sep 28, 2025
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 28, 2025
bors added a commit that referenced this pull request Sep 29, 2025
…oboet

Skip stack overflow handler for panic=immediate-abort

std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deli
8000
berately *don't* want nice messages, they want minimum binary size.

Therefore, skip the entire guard signal handler setup, which saves a lot of bytes.

I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo.

`size` reports significant savings:

```
   text	   data	    bss	    dec	    hex	filename
  15252	   1032	    104	  16388	   4004	tiny-before
   6881	    964	     48	   7893	   1ed5	tiny-after2
```

`nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`.

The impact on the error message is minimal, as the message was already
missing.

before:
```
fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort)
```

after:
```
fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error)
```

I didn't test the Windows part, but it likely also has savings.
@bors
Copy link
Collaborator
bors commented Sep 29, 2025

⌛ Testing commit 660a348 with merge c20f5e9...

Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 29, 2025
…erflow, r=joboet

Skip stack overflow handler for panic=immediate-abort

std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately *don't* want nice messages, they want minimum binary size.

Therefore, skip the entire guard signal handler setup, which saves a lot of bytes.

I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo.

`size` reports significant savings:

```
   text	   data	    bss	    dec	    hex	filename
  15252	   1032	    104	  16388	   4004	tiny-before
   6881	    964	     48	   7893	   1ed5	tiny-after2
```

`nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`.

The impact on the error message is minimal, as the message was already
missing.

before:
```
fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort)
```

after:
```
fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error)
```

I didn't test the Windows part, but it likely also has savings.
@Zalathar
Copy link
Contributor

Yielding to enclosing rollup.

@bors retry

bors added a commit that referenced this pull request Sep 29, 2025
Rollup of 6 pull requests

Successful merges:

 - #133477 (Detect tuple structs that are unconstructable due to re-export)
 - #140916 (Fix unuseful span in type error in some format_args!() invocations)
 - #146979 (constify Default on Nanoseconds)
 - #147090 (Skip stack overflow handler for panic=immediate-abort)
 - #147092 (Do not compute optimized MIR if code does not type-check.)
 - #147127 (Add a leading dash to linker plugin arguments in the gcc codegen)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Collaborator
bors commented Sep 29, 2025

⌛ Testing commit 660a348 with merge 772f380...

@bors
Copy link
Collaborator
bors commented Sep 29, 2025

☀️ Test successful - checks-actions
Approved by: joboet
Pushing 772f380 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 29, 2025
@bors bors merged commit 772f380 into rust-lang:master Sep 29, 2025
11 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 29, 2025
8000 Copy link
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing f957826 (parent) -> 772f380 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 772f380092b30680313b70a622cafc17f03e6bff --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. i686-gnu-nopt-2: 7825.0s -> 13369.6s (70.9%)
  2. dist-armhf-linux: 7862.3s -> 4870.0s (-38.1%)
  3. dist-aarch64-apple: 6098.6s -> 7253.4s (18.9%)
  4. aarch64-apple: 9296.2s -> 7724.9s (-16.9%)
  5. dist-aarch64-msvc: 5402.5s -> 6208.5s (14.9%)
  6. aarch64-msvc-1: 6441.4s -> 7315.3s (13.6%)
  7. x86_64-gnu-distcheck: 6839.2s -> 7710.4s (12.7%)
  8. pr-check-1: 1434.7s -> 1616.3s (12.7%)
  9. i686-gnu-2: 5607.5s -> 6127.5s (9.3%)
  10. x86_64-gnu-llvm-20-2: 6158.6s -> 5623.0s (-8.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (772f380): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.5% [2.5%, 2.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.5% [2.5%, 2.5%] 1

Cycles

Results (primary -2.6%, secondary 0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [1.4%, 3.8%] 2
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) -2.6% [-2.6%, -2.6%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 470.189s -> 469.945s (-0.05%)
Artifact size: 387.63 MiB -> 387.67 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. O-unix Operating system: Unix-like O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0