镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fix GetILToNativeMapping2 ignoring its reJitId - #136678

Merged
lateralusX merged 1 commit into
dotnet:mainfrom
pcshrosbree:fix/getiltonativemapping2-rejitid
Nov 6, 2026
Merged

lateralusX merged 1 commit into
dotnet:mainfrom
pcshrosbree:fix/getiltonativemapping2-rejitid

Conversation

@pcshrosbree

@pcshrosbree pcshrosbree commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #136669

ProfToEEInterfaceImpl::GetILToNativeMapping2 looked up the IL code version for reJitId but did not store the result, so it always used the method's default native code version. It now stores the version, and looks for native code only when a version was found. A reJitId that matches no IL version of the method now returns E_INVALIDARG instead of the default version's map. The error comes from the existing null-address check in GetILToNativeMapping3.

GetILToNativeMapping2 also takes the first native code version that has code, as GetNativeCodeStartAddresses does, so that a tier-up compile still in progress does not hide already compiled code. When the default native code version has code, reJitId 0 still returns its map.

The rejit profiler test now checks, after the ReJIT'd target method has run and before the revert:

  • for each of the method's ReJIT IDs, the test gets the native code addresses from GetNativeCodeStartAddresses and their maps from GetILToNativeMapping3. The map from GetILToNativeMapping2 must match at least one of those maps;
  • ReJIT ID 0 still returns a map, since the default version has code;
  • an unknown ReJIT ID returns E_INVALIDARG.

The test runs with tiered compilation disabled, so it does not cover a tier-up compile in progress.

Testing used main at e522423 as the base. Each runtime variant below ran the rejit test 20 times with a linux-x64 Checked runtime and DOTNET_TieredCompilation=0 (the test is optimization-sensitive):

Runtime Passed Failure
this change 20/20 none
storing the version, without checking whether one was found 0/20 an unknown ReJIT ID returned S_OK
main 0/20 the map for ReJIT ID 2 did not match the map of any native code body for that version; an unknown ReJIT ID returned S_OK

Note

This change was prepared with AI assistance (Anthropic Claude and OpenAI Codex) under my direction. AI agents ran the builds and tests on my machine. I reviewed the change and the test results before opening it.

GetILToNativeMapping2 looked up the IL code version for reJitId but did
not store the result, so it always used the method's default native code
version. Store the IL code version returned by the lookup. If no version
has that reJitId, skip the native code search, so that the call returns
E_INVALIDARG.

Take the first native code version that has code, as
GetNativeCodeStartAddresses does, so that a tier-up compile still in
progress does not hide already compiled code.

Extend the rejit profiler test to check the map returned for each ReJIT
ID, for the default version, and for an unknown ReJIT ID.

Fixes dotnet#136669
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 30, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@steveisok
steveisok requested a review from a team October 30, 2026 02:44
@lateralusX
lateralusX merged commit c3da97e into dotnet:main Nov 6, 2026
120 checks passed
@pcshrosbree

Copy link
Copy Markdown
Contributor Author

Thank you for the review and merge!

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 6, 2026
BrzVlad added a commit that referenced this pull request Nov 13, 2026
Interpreter code can be present in the set of native code versions for a
method, which holds the address of the interpreter precode there,
instead of the actual interpreter bytecode address. Some profiler APIs
(`GetILToNativeMapping2` and `GetNativeCodeStartAddresses`) were not
handling this case, crashing later when trying to obtain information
from the runtime for an invalid code address.

Should fix interpreter failures on rejit test. Additional profiler
testing was added in #136678,
which hit this bug on the interpreter runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Diagnostics-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICorProfilerInfo4::GetILToNativeMapping2 ignores its reJitId argument

2 participants