Skip to content

Missing SA_ONSTACK Flag Fix - #23

Merged
araustin01 merged 2 commits into
mainfrom
fix/ffi-error-slice-header-write
Sep 30, 2026
Merged

araustin01 merged 2 commits into
mainfrom
fix/ffi-error-slice-header-write

Conversation

@araustin01

Copy link
Copy Markdown

Description

Ksqueegee agent processes regularly panic with an unrecoverable whole-process memory-corruption fault.

Solution

libscrapli initialises Zig's std.Io.Threaded, which installs process-wide no-op handlers for SIGPIPE and SIGIO without SA_ONSTACK. Go requires every non-Go signal handler to use SA_ONSTACK. When a Go goroutine's write hits a closed peer (EPIPE — routine for gRPC/HTTP2), the kernel raises SIGPIPE and, lacking SA_ONSTACK, pushes the ~3.4 KB signal frame onto the goroutine's own small stack instead of Go's signal stack. That overflows the stack and overwrites the neighbouring goroutine's memory.

The fix is relatively simple, set SA_ONSTACK on those handlers.

@araustin01 araustin01 self-assigned this Sep 29, 2026
@araustin01 araustin01 added bug 🐛 Indicates an unexpected problem or unintended behavior do not merge ⏸️ This PR should not be merged yet and removed do not merge ⏸️ This PR should not be merged yet labels Sep 29, 2026
@araustin01
araustin01 marked this pull request as ready for review September 30, 2026 12:11
Copilot AI balanced review requested due to automatic review settings September 30, 2026 12:11

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@araustin01
araustin01 merged commit 83e3ceb into main Sep 30, 2026
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 Indicates an unexpected problem or unintended behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants