Add alignment checks to NativeFunc mark methods#348
Merged
Conversation
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
zhengyu123
previously requested changes
Jan 29, 2026
rkennke
reviewed
Jan 30, 2026
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Prevents ASAN segfault when accessing mark on non-NativeFunc strings. All mark methods now validate pointer alignment like libIndex() does. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- isMarked() → is_marked() - mark() getter → read_mark() - mark() setter → set_mark() Improves API clarity by distinguishing read/write operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Critical fix: is_aligned() had inverted logic using ~(alignment-1) instead of (alignment-1). This meant alignment checks always failed for non-NULL pointers, completely breaking the safety mechanism. Also fixed indentation in read_mark() and set_mark() to match other methods (4-space indent). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds two new test suites to prevent marking from being accidentally disabled: 1. utils_ut.cpp - Tests is_aligned() directly - Verifies aligned pointers return true - Verifies unaligned pointers return false - Critical test catches inverted logic bug 2. nativefunc_ut.cpp - Tests NativeFunc end-to-end - Verifies marks can be set and read back - Tests all mark types (THREAD_ENTRY, COMPILER_ENTRY, etc.) - Critical test: MarkingDisabledDetection fails if is_aligned() broken These tests would have caught the recent is_aligned() bug where marking was silently disabled for all non-NULL pointers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Feature: PR labels test:release, test:asan, test:tsan trigger additional test configurations. Debug always runs. Fixes: - check-for-pr: broken jq expression and variable handling - Removed dead gh-release job with invalid workflow syntax 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3262aa5 to
ae581cc
Compare
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uses hidden HTML marker (<!-- comment-id -->) to find existing comments instead of GITHUB_ACTOR which doesn't work with app tokens. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collaborator
Author
|
@rkennke @zhengyu123 I did the renames to make the code clearer. Also, added some tests and fixed the alignment check bug. The CI changes are not strictly related but they are fixing some annoyances I found when working on this. Since I really want to get this merged ASAP and create a release so we can consume it in dd-trace-java, I opted for including all those changes in this PR as separate commits. |
rkennke
requested changes
Jan 30, 2026
Contributor
rkennke
left a comment
There was a problem hiding this comment.
Looks good, but what about Zhengyu's suggestion?
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?:
Fixes NativeFunc mark methods to prevent ASAN segfaults and adds CI workflow improvements for label-based test configuration selection.
Core fix - NativeFunc marking:
isMarked,markgetter/setter)is_aligned()check pattern aslibIndex()is_aligned()helperCI workflow improvements:
test:release,test:asan,test:tsandebugconfig; labels add additional configurationscheck-for-prjob (broken jq expression)gh-releasejob with invalid workflow syntaxMotivation:
ASAN tests revealed a segfault in
NativeFunc::mark()at codeCache.h:77. The profiler was callingmark()on function names that weren't allocated viaNativeFunc::create(), causing invalid memory access.The CI changes enable easily running ASAN tests on PRs by adding the
test:asanlabel, which was needed to properly validate this fix.How to test the change?:
./gradlew :ddprof-test:testAsantest:asanlabel to the PR to trigger ASAN CI runThe fix prevents crashes when the profiler encounters native frames from libraries without proper NativeFunc metadata.
For Datadog employees:
credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
Unsure? Have a question? Request a review!
🤖 Generated with Claude Code