Skip to content

winch: restore aarch64 frame pointer before advancing SP - #14516

Merged
saulecabrera merged 2 commits into
bytecodealliance:mainfrom
macovedj:fix-winch-aarch64-tail-call-sp
Oct 5, 2026
Merged

saulecabrera merged 2 commits into
bytecodealliance:mainfrom
macovedj:fix-winch-aarch64-tail-call-sp

Conversation

@macovedj

@macovedj macovedj commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

When a function with stack arguments tail-calls a callee with no stack arguments, Winch’s AArch64 backend advances SP past the saved frame pointer before reloading it. A signal handler running between those instructions can overwrite the saved FP.

This PR computes the callee’s entry SP in a scratch register, restores FP while the old frame is still protected, and then updates SP.

Fixes #14503.

Compute the empty tail callee entry SP in a scratch register, then reload
the saved FP before releasing the old frame. This prevents a signal
handler from overwriting the saved FP before it is read.

Add disassembly coverage for both small and large entry-SP offsets.

Fixes bytecodealliance#14503.
@macovedj
macovedj requested review from a team as code owners October 3, 2026 16:24
@macovedj
macovedj requested review from cfallin and removed request for a team October 3, 2026 16:24
@github-actions github-actions Bot added the winch Winch issues or pull requests label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Subscribe to Label Action

cc @saulecabrera

Details This issue or pull request has been labeled: "winch"

Thus the following users have been cc'd because of the following labels:

  • saulecabrera: winch

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Comment thread winch/codegen/src/isa/aarch64/masm.rs Outdated
Use a common helper to calculate the callee entry SP, restore
frame state, and then update SP for empty and resizing tail calls.
This keeps their frame restoration ordering from drifting.
@saulecabrera
saulecabrera added this pull request to the merge queue Oct 5, 2026
Merged via the queue into bytecodealliance:main with commit 6e5693a Oct 5, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

winch Winch issues or pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Winch: tail calls on aarch64 may read data below the current sp

2 participants