Adopt JmpCtxScope for setting stack walk siglongjmp protection - #758
Merged
Conversation
Contributor
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||
Contributor
Contributor
CI Test ResultsRun: #33081778630 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-08-27 14:51:02 UTC |
jbachorik
approved these changes
Aug 27, 2026
jbachorik
left a comment
Collaborator
There was a problem hiding this comment.
This looks good. Nice cleanup!
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 does this PR do?:
Replaces the hand-rolled
sigjmp_buf* prev = prof_thread->getJmpCtx(); ... prof_thread->setJmpCtx(prev);siglongjmp-chaining pattern with the RAIIJmpCtxScopeguard (introduced in #743 forHotspotSupport::resolve()) across the remaining stack-walking entry points:HotspotSupport::walkVM()HotspotSupport::walkJavaStack()StackWalker::walkFP()StackWalker::walkDwarf()Per site:
sigjmp_buf* prev_jmp_buf = getJmpCtx();→JmpCtxScope jmp_scope(prof_thread);setJmpCtx(&crash_protection_ctx);→jmp_scope.install(&crash_protection_ctx);setJmpCtx(prev_jmp_buf);→jmp_scope.restore();(still an explicit disarm before touching anything else that could fault)setJmpCtx(prev_jmp_buf);is dropped inwalkFP/walkDwarf/walkJavaStack— nothing after the walk loop can fault, so the guard's destructor restoring at function exit is sufficient. InwalkVM, the explicitjmp_scope.restore()at thedone:label is kept, since post-walk work in that frame (leaf-drop, counters) doesn't need the landing pad held live.guards.his now included bystackWalker.cpp(hotspotSupport.cppalready had it from #743).Motivation:
Consolidate the siglongjmp landing-pad save/restore/chain logic behind one RAII abstraction instead of four duplicated get/set call sites, so every exit path (normal return, fault recovery,
goto) is guaranteed to reinstate the previous landing pad without relying on the author remembering to add the restore call.Additional Notes:
No functional/behavioral change intended — this is a pure refactor onto the existing
JmpCtxScopeabstraction from #743.JmpCtxScope's constructor snapshots the previous landing pad beforeinstall()overwrites it, andrestore()/the destructor always write that fixed snapshot, so it is safe to callrestore()explicitly and then let the destructor run again at scope exit.How to test the change?:
./gradlew buildDebugcompiles clean. No behavior change, so existing stack-walking/crash-protection test coverage applies unchanged.For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.Unsure? Have a question? Request a review!