René's URL Explorer Experiment


Title: Fix thread safety, walkVM anchor recovery, and musl compatibility by jbachorik · Pull Request #400 · DataDog/java-profiler · GitHub

Open Graph Title: Fix thread safety, walkVM anchor recovery, and musl compatibility by jbachorik · Pull Request #400 · DataDog/java-profiler

X Title: Fix thread safety, walkVM anchor recovery, and musl compatibility by jbachorik · Pull Request #400 · DataDog/java-profiler

Description: What does this PR do?: Fixes crashes and assertion failures caused by VMThread accessor calls on non-JavaThread types and partially-initialized threads. Adds walkVM anchor recovery for interpreter frames on musl (where DWARF CFI is absent in __syscall_cp_asm). Enables CSTACK_VM as the default stack walking mode on Linux with proper safety guards. Commits: Scan all native libs for thread entry points — replaces fragile findJvmLibrary/findLibraryByName with a full scan, fixing thread entry detection on glibc, musl, and Rust binaries Guard JavaThread-specific VMThread accessors for non-JavaThread safety — guards anchor(), inDeopt(), compiledMethod() with cachedIsJavaThread(); adds isThreadAccessible() check in walkVM/checkFault for partially-mapped threads (GraalVM 25 aarch64); fixes torn write in cacheJavaThread() Fix test infrastructure for cross-platform stability — CStackInjector fallback for J9; TagContextTest pins cstack=default Suppress debug asserts in at()/cast_to() under crash protection — avoids assertion failures when crash-protected code dereferences suspect pointers Restore error frames for truncated stacks in walkVM — break_no_anchor for JavaThreads when symbol resolution fails; break_no_symbol for non-Java threads where JavaFrameAnchor is inapplicable Fix pthread_key_t sentinel for musl — key value 0 is valid on musl (glibc reserves it); uses volatile bool flag instead. Removes stale TLS priming declarations Add walkVM anchor recovery for interpreter frames on musl — when DWARF unwinding can't reach Java frames (musl's __syscall_cp_asm lacks .cfi directives), reads interpreter frames directly from VMJavaFrameAnchor's FP. Uses x86_64 HotSpot convention (lastJavaFP != 0 → interpreter frame) with getMethodId()+validatedId() safety. Includes inline recovery mid-loop, post-loop fallback, and getFrame() redirect. All anchor paths validate sp bounds and depth limits before re-entering the unwind loop Report aborted tests as SKIPPED in ProfilerTestRunner — JUnit ABORTED status was conflated with FAILED, causing false test failures on musl Motivation: While porting native memory allocation profiler support from async-profiler, running walkVM on more native threads exposed crashes from unchecked anchor()/inDeopt()/compiledMethod() calls on non-JavaThread types. On musl-amd64, CSTACK_VM (now the default on Linux) produced zero Java frames because DWARF unwinding couldn't bridge the gap through __syscall_cp_asm (which lacks CFI directives) to reach the Java frame area. Additional Notes: The CSTACK_VM default gives richer mixed Java+native stack traces. Previously this caused crashes because anchor(), inDeopt(), and compiledMethod() assumed they were always called on JavaThread instances. The cachedIsJavaThread() guard caches the vtable check in ProfiledThread for O(1) subsequent lookups. On musl-amd64, the walkVM anchor recovery works as follows: DWARF unwinding processes native frames until it hits __syscall_cp_asm (no FDE) FrameDesc::default_frame advances SP via fp + 16, which doesn't bridge the gap When method_name == NULL (unresolvable frame) and anchor is available, the inline recovery reads the interpreter frame directly from anchor->lastJavaFP() using InterpreterFrame::method_offset If the inline path doesn't fire, the post-loop fallback tries the same approach after DWARF exhaustion Both paths validate sp bounds (sp < bottom, alignment) before goto unwind_loop How to test the change?: ./gradlew :ddprof-lib:buildDebug ./utils/run-docker-tests.sh --mount --libc=glibc --arch=aarch64 --jdk=25 \ --tests="*BoundMethodHandleMetadataSizeTest*" ./utils/run-docker-tests.sh --mount --libc=musl --arch=x64 --jdk=17 \ --tests="*TagContextTest*" ./utils/run-docker-tests.sh --mount --libc=glibc --tests="*NativeThreadTest*" ./utils/run-docker-tests.sh --mount --libc=musl --tests=".*NativeThreadTest.*" For Datadog employees: If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance. This PR doesn't touch any of that. JIRA: [JIRA-XXXX] 🤖 Generated with Claude Code

Open Graph Description: What does this PR do?: Fixes crashes and assertion failures caused by VMThread accessor calls on non-JavaThread types and partially-initialized threads. Adds walkVM anchor recovery for interpreter ...

X Description: What does this PR do?: Fixes crashes and assertion failures caused by VMThread accessor calls on non-JavaThread types and partially-initialized threads. Adds walkVM anchor recovery for interpreter ...

Opengraph URL: https://github.com/DataDog/java-profiler/pull/400

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:0ac5ac9f-a9e2-e7d0-908b-dc626e385405
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8776:C4024:4BF664D:65CC859:6A655A6A
html-safe-nonce7b4970de0afde6015044b3abdb1bd8725944752d602d80600cdda0e80665af59
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Nzc2OkM0MDI0OjRCRjY2NEQ6NjVDQzg1OTo2QTY1NUE2QSIsInZpc2l0b3JfaWQiOiI3MzM1NzQ4OTE4NjYzNTM1MjEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac6832371d44d7cce94436cf7aa96254555812cdf4d37282729c522c22ee4003a5
hovercard-subject-tagpull_request:3331663290
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
twitter:imagehttps://avatars.githubusercontent.com/u/738413?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/738413?s=400&v=4
og:image:altWhat does this PR do?: Fixes crashes and assertion failures caused by VMThread accessor calls on non-JavaThread types and partially-initialized threads. Adds walkVM anchor recovery for interpreter ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/DataDog/java-profiler git https://github.com/DataDog/java-profiler.git
octolytics-dimension-user_id365230
octolytics-dimension-user_loginDataDog
octolytics-dimension-repository_id585532470
octolytics-dimension-repository_nwoDataDog/java-profiler
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id585532470
octolytics-dimension-repository_network_root_nwoDataDog/java-profiler
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FDataDog%2Fjava-profiler%2Fpull%2F400%2Fcommits%2Fa79bafa48aee426a1676917ab6d701126880b869
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FDataDog%2Fjava-profiler%2Fpull%2F400%2Fcommits%2Fa79bafa48aee426a1676917ab6d701126880b869
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=DataDog%2Fjava-profiler
Reloadhttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
Reloadhttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
Reloadhttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
Please reload this pagehttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
DataDog https://github.com/DataDog
java-profilerhttps://github.com/DataDog/java-profiler
Notifications https://github.com/login?return_to=%2FDataDog%2Fjava-profiler
Fork 12 https://github.com/login?return_to=%2FDataDog%2Fjava-profiler
Star 33 https://github.com/login?return_to=%2FDataDog%2Fjava-profiler
Code https://github.com/DataDog/java-profiler
Issues 10 https://github.com/DataDog/java-profiler/issues
Pull requests 20 https://github.com/DataDog/java-profiler/pulls
Actions https://github.com/DataDog/java-profiler/actions
Security and quality 0 https://github.com/DataDog/java-profiler/security
Insights https://github.com/DataDog/java-profiler/pulse
Code https://github.com/DataDog/java-profiler
Issues https://github.com/DataDog/java-profiler/issues
Pull requests https://github.com/DataDog/java-profiler/pulls
Actions https://github.com/DataDog/java-profiler/actions
Security and quality https://github.com/DataDog/java-profiler/security
Insights https://github.com/DataDog/java-profiler/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FDataDog%2Fjava-profiler%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FDataDog%2Fjava-profiler%2Fissues%2Fnew%2Fchoose
jbachorikhttps://github.com/jbachorik
mainhttps://github.com/DataDog/java-profiler/tree/main
jb/thread_fixeshttps://github.com/DataDog/java-profiler/tree/jb/thread_fixes
Conversation 9 https://github.com/DataDog/java-profiler/pull/400
Commits 16 https://github.com/DataDog/java-profiler/pull/400/commits
Checks 83 https://github.com/DataDog/java-profiler/pull/400/checks
Files changed https://github.com/DataDog/java-profiler/pull/400/files
Please reload this pagehttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
Fix thread safety, walkVM anchor recovery, and musl compatibility https://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869#top
Show all changes 16 commits https://github.com/DataDog/java-profiler/pull/400/files
a79bafa Scan all native libs for thread entry points jbachorik Feb 26, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
75398e2 Guard JavaThread-specific VMThread accessors for non-JavaThread safety jbachorik Feb 26, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/75398e2949df0cc8d1b4c6eafed50ef67347b7c5
1c39a6b Fix test infrastructure for cross-platform stability jbachorik Feb 26, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/1c39a6b8a7b06ff48885c43b536ad6accfe18b9e
e267481 Suppress debug asserts in at()/cast_to() under crash protection jbachorik Feb 27, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/e267481da12373ea69087142838726ee8f16edc4
4b7ea59 Restore error frames for truncated stacks in walkVM jbachorik Feb 27, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/4b7ea59e7a860a5fc4a9c45346e5ee2a7f11b84e
7207ff2 Fix pthread_key_t sentinel for musl (key 0 is valid) jbachorik Feb 28, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/7207ff2306461d5163ebd58af7b18f0558e713e3
e1becaa Add walkVM anchor recovery for interpreter frames on musl jbachorik Mar 2, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/e1becaa01d6e33403705e4ccfb34ef608cb87c1c
6de7c9c Report aborted tests as SKIPPED in ProfilerTestRunner jbachorik Mar 2, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/6de7c9c54d690fcc7eff774afb19b4de98ed0ad8
d0193b2 Fix misleading comment on lastJavaPC CodeHeap check jbachorik Mar 2, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/d0193b235e50ba41719d1e2bdc717e10f9d5e90f
c73ec55 Fix inaccurate comments in walkVM jbachorik Mar 2, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/c73ec55052b75953aec99559cefe87ca8a2cd0ac
955d1c5 Fix _tls_key_initialized ordering: volatile→store-release/load-acquire jbachorik Mar 2, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/955d1c50a6793420b9679b5b296dfee66a9f3f23
9d6bd7b Remove debug code from TagContextTest jbachorik Mar 2, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/9d6bd7b0090916c15baf68b31c3e77a6380c332e
d024e72 Restore TagContextTest to main state jbachorik Mar 2, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/d024e72a14e6fd55febc843b2e1b523199e911f5
8ad204d Extract 'isAnchorInterpreter' function jbachorik Mar 3, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/8ad204d2ea19171cd20911ee658647c86f100cc6
21f3193 Extract 'isAnchorInterpreter' function jbachorik Mar 3, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/21f319345041bc15b524b353ba5409c96197443d
1ce7db7 Merge branch 'jb/thread_fixes' of https://github.com/DataDog/java-pro… jbachorik Mar 3, 2026 https://github.com/DataDog/java-profiler/pull/400/commits/1ce7db75c83e8b7d1439e4f84949c84ed99b67ee
Clear filters https://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
Please reload this pagehttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
Please reload this pagehttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
Next https://github.com/DataDog/java-profiler/pull/400/commits/75398e2949df0cc8d1b4c6eafed50ef67347b7c5
Please reload this pagehttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869
https://github.com/jbachorik
https://github.com/claude
jbachorikhttps://github.com/DataDog/java-profiler/commits?author=jbachorik
claudehttps://github.com/DataDog/java-profiler/commits?author=claude
https://github.com/DataDog/java-profiler/blob/main/.github/CODEOWNERS#L4
ddprof-lib/src/main/cpp/vmEntry.cpphttps://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869#diff-c86f18cf6c9cbe7547996ba0f4d1e5b63ea694ffb800ee08176a2708c41e5bdc
View file https://github.com/DataDog/java-profiler/blob/a79bafa48aee426a1676917ab6d701126880b869/ddprof-lib/src/main/cpp/vmEntry.cpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/DataDog/java-profiler/pull/400/commits/{{ revealButtonHref }}
https://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869#diff-c86f18cf6c9cbe7547996ba0f4d1e5b63ea694ffb800ee08176a2708c41e5bdc
https://github.com/DataDog/java-profiler/pull/400/commits/a79bafa48aee426a1676917ab6d701126880b869#diff-c86f18cf6c9cbe7547996ba0f4d1e5b63ea694ffb800ee08176a2708c41e5bdc
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.