Skip to content

systrap: shift the spinning queue by the stub gap - #15573

Merged
copybara-service[bot] merged 1 commit into
gvisor:masterfrom
NahumLitvin:systrap-spinq-gap
Oct 9, 2026
Merged

copybara-service[bot] merged 1 commit into
gvisor:masterfrom
NahumLitvin:systrap-spinq-gap

Conversation

@NahumLitvin

Copy link
Copy Markdown
Contributor

stubSpinningThreadQueueAddr was the only region after the gap that didn't move with it, so a small gap puts the queue on top of a sysmsg stack and stubs spin forever in spinning_queue_remove_first.

Adds the missing shift and a test that the queue sits between the context queue and context region. On arm64 the test fails 3/3 without the fix and passes 3/3 with it.

Fixes #15572

Assisted-by: Claude Code

stubSpinningThreadQueueAddr was the only stub region after the gap that
didn't move with it. With a small gap, the relocated sysmsg stacks or the
context queue land on top of it, and stubs spin forever in
spinning_queue_remove_first.

Fixes gvisor#15572

Assisted-by: Claude Code
Signed-off-by: Nahum Litvin <[email protected]>
@NahumLitvin

Copy link
Copy Markdown
Contributor Author

The new test only shows the queue is misplaced. To see the actual hang I put a small repro tool on a branch: https://github.com/NahumLitvin/gvisor/tree/systrap-triage/tools/systrap-triage

From a go branch checkout, as root on Linux:

./tools/systrap-triage/scenarios/spinq-gap/run.sh --src /path/to/gvisor-go --out /tmp/spinq-gap

It builds master with a debug-only patch that forces gap so the unshifted queue lands in a per-thread stack region, plus the same build with this fix, and runs a 16-thread getpid workload under systrap. The page inside the region still follows stubStart, so it takes a few runs. What I got on arm64:

build queue on page 6 other pages
master + forced gap hung every time (3/3), stubs at 100% CPU, no "context is stuck" log clean
this PR + forced gap 3/3 clean 21/21 clean

On a hang the collector shows the queue address inside the memfd:systrap-memory stack mapping and the stub pc in spinning_queue_remove_first (sysmsg_lib.c:193-197). REPRO.md there is written so a person or an agent can follow it. Page 7 with master exits 137 within a second, I haven't dug into that one yet.

@NahumLitvin

Copy link
Copy Markdown
Contributor Author

@avagin @konstantin-s-bogom could you take a look? One line plus a layout test. @avagin this is the spinning queue from 0cbe6fc, the repro tool is linked in the comment above.

@konstantin-s-bogom konstantin-s-bogom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix

@konstantin-s-bogom konstantin-s-bogom added the ready to pull Causes the PR to be imported into Google. Will be removed soon. label Oct 9, 2026
copybara-service Bot pushed a commit that referenced this pull request Oct 9, 2026
`stubSpinningThreadQueueAddr` was the only region after the gap that didn't move with it, so a small `gap` puts the queue on top of a sysmsg stack and stubs spin forever in `spinning_queue_remove_first`.

Adds the missing shift and a test that the queue sits between the context queue and context region. On arm64 the test fails 3/3 without the fix and passes 3/3 with it.

Fixes #15572

Assisted-by: Claude Code
FUTURE_COPYBARA_INTEGRATE_REVIEW=#15573 from NahumLitvin:systrap-spinq-gap c7f458a
PiperOrigin-RevId: 996619645
@copybara-service
copybara-service Bot merged commit 87ba3a7 into gvisor:master Oct 9, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to pull Causes the PR to be imported into Google. Will be removed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

systrap: spinning queue isn't shifted by the stub gap, aliases a sysmsg stack and wedges the sandbox

2 participants