Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DataDog/java-profiler
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: DataDog/java-profiler
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: jb/native_allocs
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 8 commits
  • 21 files changed
  • 2 contributors

Commits on Feb 25, 2026

  1. Port native malloc/free profiling from async-profiler

    - Add MallocTracer engine (GOT/PLT patching for malloc/calloc/realloc/free/posix_memalign/aligned_alloc)
    - Add BCI_NATIVE_MALLOC, MallocEvent, T_MALLOC/T_FREE JFR types
    - Add nativemem/nofree arguments
    - Add profiler.Malloc and profiler.Free JFR event metadata
    - Add recordEventOnly() for stack-trace-less free events
    - Add NativememProfilerTest and NofreeNativememProfilerTest
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    2a3ee88 View commit details
    Browse the repository at this point in the history
  2. Fix pointer safety issues in MallocTracer

    - Guard SAVE_IMPORT against NULL findImport return
    - Skip patchImport calls when corresponding _orig_* is NULL
    - Guard detectNestedMalloc against NULL _orig_malloc/_orig_calloc
    - Fix realloc(ptr,0)->NULL not recording free (POSIX: frees ptr)
    - Move _running=true after patchLibraries() to prevent hooks firing before patches are applied
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    a4a8eb2 View commit details
    Browse the repository at this point in the history
  3. Fix stack traces for native malloc events

    - Use putVar64 for call_trace_id in recordMallocSample (was putVar32,
      silently truncating 64-bit IDs → all malloc events had null stacks)
    - Walk Java stack via walkVM for BCI_NATIVE_MALLOC with cstack >= VM
    - Default cstack to CSTACK_VM; fall back gracefully if VMStructs absent
    - Add NativememProfilerTest and NofreeNativememProfilerTest smoke tests
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    fb72985 View commit details
    Browse the repository at this point in the history
  4. Add native memory profiling architecture doc

    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    e6ae01f View commit details
    Browse the repository at this point in the history
  5. Fix three CI test failures

    - vmEntry.cpp: use findLibraryByName for libc/libpthread; findJvmLibrary
      always returns libjvm on HotSpot so start_thread was never marked
      MARK_THREAD_ENTRY, causing break_no_anchor frames on aarch64
    - CStackInjector: return first @valuesource entry as fallback when all
      modes are filtered (J9 with {"vm","vmx"}); prevents PreconditionViolation
      and lets isPlatformSupported() skip cleanly
    - TagContextTest: pin cstack=default; test covers context tagging, not
      stack-walking mode; CSTACK_VM is unreliable on musl x64 CI runners
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    4175162 View commit details
    Browse the repository at this point in the history
  6. Fix break_no_anchor for native threads with CSTACK_VM default

    walkVM emits break_no_anchor when it reaches the top of a pure-native
    thread stack without a JavaFrameAnchor anchor. The previous fix used
    findLibraryByName("libc") which does a prefix match and can return the
    wrong library (e.g. libcap instead of libc.so.6), causing ThreadEntry-
    DetectionTest to regress on amd64 without fixing aarch64.
    
    Correct fix: scan ALL loaded native libs for isThreadEntry patterns once
    at init. This covers start_thread in glibc (libc.so.6 or libpthread.so.0
    depending on version), musl (libc.musl-<arch>.so.1), Rust app binaries,
    etc., without any fragile library name lookup.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    2e27e4b View commit details
    Browse the repository at this point in the history
  7. Suppress break_no_anchor error frames for non-malloc events

    For CPU/WALL samples, break_no_anchor is a normal stack-walk
    termination (pure-native threads, invalid anchor on aarch64
    compiler threads). Emitting an error frame there breaks test
    assertions. Reserve the frame for MALLOC_SAMPLE where it
    carries diagnostic value.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    2b3b2d9 View commit details
    Browse the repository at this point in the history
  8. Drop break_no_anchor error frames entirely

    The anchor-not-set condition (sp==0, invalid sp range) just means
    the JVM hasn't established a JavaFrameAnchor yet for this transition.
    The native frames already captured above are the complete information;
    the error frame adds no diagnostic value for any event type.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    jbachorik and claude committed Feb 25, 2026
    Configuration menu
    Copy the full SHA
    84d3c57 View commit details
    Browse the repository at this point in the history
Loading