Skip to content

[Apple mobile] Handle missing IL-to-native map in DebuggerJitInfo#128764

Open
kotlarmilos wants to merge 2 commits into
dotnet:mainfrom
kotlarmilos:kotlarmilos/fix-debugger-il-native-null-map
Open

[Apple mobile] Handle missing IL-to-native map in DebuggerJitInfo#128764
kotlarmilos wants to merge 2 commits into
dotnet:mainfrom
kotlarmilos:kotlarmilos/fix-debugger-il-native-null-map

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented May 29, 2026

Description

DebuggerJitInfo::MapILOffsetToNative dereferences the entry returned by MapILOffsetToMapEntry without checking for NULL, which crashes when m_sequenceMap is NULL. This is the expected state for ReadyToRun-precompiled methods that ship without IL-to-native debug info. The crash reproduces on the first R2R framework method call under the CoreCLR remote debugger.

The fix is to return a (SIZE_T)-1 sentinel from MapILOffsetToNative, MapILOffsetToNativeForSetIP, and GetSrcTypeFromILOffset when the map is missing, and skip sentinel funclet entries in AddBindAndActivateILReplicaPatch.

…itInfo

DebuggerJitInfo::MapILOffsetToNative dereferences the entry returned by
MapILOffsetToMapEntry without checking for NULL, which crashes when
m_sequenceMap is NULL. This is the normal state for ReadyToRun-precompiled
methods that ship without IL-to-native debug info (most framework code in
iOS Debug builds). The crash reproduces on the first R2R framework method
call under the CoreCLR remote debugger: ReadyToRunInfo::GetEntryPoint
triggers Debugger::JITComplete -> MapAndBindFunctionPatches ->
AddBindAndActivateILReplicaPatch -> MapILOffsetToNative, which derefs NULL
and kills the process before the debug session attaches.

Return a (SIZE_T)-1 sentinel from MapILOffsetToNative,
MapILOffsetToNativeForSetIP, and GetSrcTypeFromILOffset when the map is
missing, and skip sentinel funclet entries in
AddBindAndActivateILReplicaPatch. The sentinel is already the convention
used by ILToNativeOffsetIterator::Next. Behavior for methods with a valid
sequence map is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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.

Copy link
Copy Markdown
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 hardens CoreCLR debugger IL-to-native mapping paths for methods that lack sequence maps, such as ReadyToRun framework methods on Apple mobile, avoiding null dereferences during debugger patch binding.

Changes:

  • Treat missing/empty sequence maps as unmappable in DebuggerJitInfo helpers.
  • Return existing sentinel values for missing IL-to-native mappings.
  • Skip sentinel native offsets when binding IL replica patches.
Show a summary per file
File Description
src/coreclr/debug/ee/functioninfo.cpp Adds null handling for sequence-map lookups and sentinel returns for missing mappings.
src/coreclr/debug/ee/controller.cpp Avoids binding patches for sentinel native offsets from the iterator.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread src/coreclr/debug/ee/functioninfo.cpp
Comment thread src/coreclr/debug/ee/functioninfo.cpp Outdated
@kotlarmilos kotlarmilos changed the title [Apple mobile] Debug/EE: handle missing IL-to-native map in DebuggerJitInfo [Apple mobile] Handle missing IL-to-native map in DebuggerJitInfo May 29, 2026
Move pointer arithmetic on the sequence map base after the NULL guard
in MapILOffsetToMapEntry and MapILOffsetToNativeForSetIP so the
missing-map path never performs arithmetic on a NULL pointer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos kotlarmilos added this to the 11.0.0 milestone May 29, 2026
@janvorli
Copy link
Copy Markdown
Member

@kotlarmilos why don't we have the same problem without interpreter (JIT+R2R) on other platforms?

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.

3 participants