fix: preserve XMM6-XMM15 in x86_64 bthread context switch - #3495
Open
zchuango wants to merge 2 commits into
Open
fix: preserve XMM6-XMM15 in x86_64 bthread context switch#3495zchuango wants to merge 2 commits into
zchuango wants to merge 2 commits into
Conversation
Co-authored-by: LinQuickDev <LinQuickDev@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a Linux x86_64 Clang crash (issue #2781) by extending bthread’s x86_64 context-switch frame to preserve SIMD state across bthread_jump_fcontext, and updating dependent tooling that decodes saved contexts.
Changes:
- Save/restore XMM6–XMM15 during Linux x86_64 bthread context switches and expand the saved frame accordingly.
- Update
bthread_make_fcontextto match the new frame layout (including updated MXCSR/x87 control-word offsets). - Update
TaskTracer’s register-slot indices to match the new saved-context layout.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/bthread/context.cpp | Expands Linux x86_64 fcontext frame and saves/restores XMM6–XMM15; updates MXCSR/x87 CW offsets and make_fcontext layout. |
| src/bthread/task_tracer.cpp | Adjusts libunwind cursor register-slot indices to match the expanded Linux x86_64 fcontext frame. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Author
|
Hi @wwbmmm @chenBright , the Copilot review comments have been addressed and the updated CI is passing. Could you please take a look when you have time? Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: resolve #2781
Problem Summary:
When brpc is built with Clang on Linux x86_64, running
example/streaming_echo_c++may crash.This PR preserves XMM6-XMM15 during Linux x86_64 bthread context switches
and updates the corresponding context-frame layout.
What is changed and the side effects?
Changed:
bthread_jump_fcontext.bthread_make_fcontextconsistent with the new frame layout.TaskTracer.Side effects:
Performance effects:
Breaking backward compatibility:
Verification
Verified on Linux x86_64 with Clang 18.1.3.
After this change:
streaming_echo_c++starts and runs normally;Environment
Server
Client
Check List: