Skip to content

Conversation

@tommcdon
Copy link
Member

@tommcdon tommcdon commented Dec 8, 2025

Fixes #120419. The implementation of JIT dumps in the linux perf tool creates dynamic shared objects representing JIT'd methods. In .NET 10, #113943 changed the default granularity for stubs, which now reports the block of memory that stores stubs instead of the individual methods. If the event is fired before the block memory is committed (only is reserved), PerfJitDumpState::LogMethod fails to read the memory from the block and then all subsequent JIT dump events will fail. The linux perf tool will favor jit dumps over perfmaps if jit dumps are available, which breaks DOTNET_PerfMapEnabled=1 or 2 settings. This fix addresses the issue by no longer reporting the code byte for block allocations, which is only enabled when DOTNET_PerfMapStubGranularity is set to 0 or 1.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue (#120419) where JIT dumps fail when reporting stub blocks whose memory is reserved but not yet committed. The fix prevents writing code bytes for block-level allocations while maintaining backward compatibility for individual method reporting.

  • Adds a reportCodeBlock boolean parameter to PAL_PerfJitDump_LogMethod (defaults to true)
  • Updates the stub logging logic to skip code bytes for block-type allocations
  • Removes dead code check that would never execute

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/coreclr/pal/inc/pal.h Adds reportCodeBlock parameter with default value true to maintain backward compatibility
src/coreclr/pal/src/misc/perfjitdump.cpp Implements conditional code size reporting based on reportCodeBlock parameter; removes dead code check
src/coreclr/vm/perfmap.cpp Updates call site to pass false for block-type stub allocations

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

{ &record, sizeof(JitCodeLoadRecord) },
{ (void *)symbol, symbolLen + 1 },
{ pCode, codeSize },
{ pCode, reportedCodeSize },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any issues that we potentially report a different code size here compared to the record? What value will it have to write the record when reportedCodeSize is 0 compared to not report anything for PerfMapStubType::Block?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOTNET_PerfMapEnabled behavior in .NET 10.0

2 participants