Skip to content

Fix R2RDump ArgumentOutOfRangeException for composite LVB images#126387

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-r2rdump-argument-out-of-range
Open

Fix R2RDump ArgumentOutOfRangeException for composite LVB images#126387
Copilot wants to merge 2 commits intomainfrom
copilot/fix-r2rdump-argument-out-of-range

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

In Large Version Bubble (LVB) composite R2R images, ManifestReferenceAssemblies contains more entries than ReadyToRunAssemblyHeaders — the manifest includes extra version-bubble assembly references beyond the actual component assemblies. TextDumper.DumpHeader iterated over the manifest list while indexing into the shorter headers list, throwing ArgumentOutOfRangeException.

Changes

  • src/coreclr/tools/r2rdump/TextDumper.cs: Add a bounds check in the composite assembly loop to break when assemblyIndex >= ReadyToRunAssemblyHeaders.Count, preventing the out-of-range access when manifest references outnumber assembly headers.
foreach (string assemblyName in _r2r.ManifestReferenceAssemblies.OrderBy(kvp => kvp.Value).Select(kvp => kvp.Key))
{
+   if (assemblyIndex >= _r2r.ReadyToRunAssemblyHeaders.Count)
+       break;
    Guid mvid = _r2r.GetAssemblyMvid(assemblyIndex);
    ...
}
Original prompt

Create a pull request against dotnet/runtime by cherry-picking commit a6713ccb28fa831629168ef0a949ada7966921b5 onto upstream/main.

Context:

  • The commit originates from an existing PR in jtschuster/runtime and contains the fix for R2RDump crashing with ArgumentOutOfRangeException for composite LVB images.
  • The resulting PR should target the main branch of dotnet/runtime.

Requested work:

  1. Check out a branch based on the latest upstream/main.
  2. Cherry-pick commit a6713ccb28fa831629168ef0a949ada7966921b5 onto that branch.
  3. Resolve any conflicts if needed while preserving the intent of the fix.
  4. Push the branch to a fork suitable for opening a PR to dotnet/runtime.
  5. Open a pull request against dotnet/runtime:main.

PR content guidance:

  • Use a concise, descriptive title reflecting the R2RDump fix.
  • Include a short description of the root cause and the bounds-check fix.
  • Mention that the change prevents ArgumentOutOfRangeException when dumping composite Large Version Bubble images.

Please complete the PR creation end-to-end if permissions and repository setup allow.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: how do I change the target of this PR to be on dotnet/runtime

Assistant: You can’t directly retarget that existing PR from jtschuster/runtime to dotnet/runtime.

A GitHub PR is tied to the base repository it was opened against. Your current PR #27 is from:

  • head: jtschuster:copilot/fix-r2rdump-argumentoutofrangeexception
  • base: jtschuster/runtime:main

GitHub lets you change the base branch within the same repository, but not move a PR from one repository to a different repository. So you need to create a new PR against dotnet/runtime instead.

What to do

  1. Make sure your branch is available in a fork of dotnet/runtime that you control.
    • Usually this means your fork is jtschuster/runtime, which you already have.
  2. Open a new PR from:
    • head: jtschuster:copilot/fix-r2rdump-argumentoutofrangeexception
    • base: dotnet/runtime:main
  3. Then close the old PR in jtschuster/runtime if you no longer need it.

Fastest way in the GitHub UI

If your branch exists on your fork, go to the PR creation page for dotnet/runtime and choose:

  • base repository: dotnet/runtime
  • base branch: main
  • head repository: jtschuster/runtime
  • compare branch: copilot/fix-r2rdump-argumentoutofrangeexception

GitHub docs for changing PR targets and base branches are here: Changing the base branch of a pull request and Creating a pull request from a fork.

If GitHub won’t show the branch

Push the branch to your fork explicitly, then open the new PR:

git checkout copilot/fix-r2rdump-argumentoutofrangeexception
git push -u origin copilot/fix-r2rdump-argumentoutofrangeexception

Then create the PR against dotnet/runtime.

Important caveat

If jtschuster/runtime is not actually a fork of dotnet/runtime, GitHub may not allow the cross-repo PR automatically in the UI. In that case:

  1. Fork dotnet/runtime to your account.
  2. Push this branch/cherry-pick these commits into that fork.
  3. Open the PR from your fork to dotnet/runtime:main.

If you want, I can help you with the exact git commands to move this branch onto a proper fork and open the replacement PR.

User: Can you cherry-pick a6713cc on top of upstream/main and make a PR for it on dotnet/runtime?

Assistant: I'm waiting for your response to the pull-request tool prompt so I can continue.

This pull request was created from Copilot chat.

In Large Version Bubble (LVB) composite mode, ManifestReferenceAssemblies
contains more entries than ReadyToRunAssemblyHeaders because the manifest
includes extra assembly references for the version bubble. The loop in
DumpHeader iterated over all manifest references but indexed into the
shorter assembly headers list, causing an ArgumentOutOfRangeException.

Add a bounds check to break out of the loop when assembly headers are
exhausted.

Cherry-picked from jtschuster/runtime@a6713cc
Co-authored-by: jtschuster <36744439+jtschuster@users.noreply.github.com>

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/66878142-2700-416a-bb14-609f819de1a5
Copilot AI changed the title [WIP] Fix R2RDump crashing with ArgumentOutOfRangeException Fix R2RDump ArgumentOutOfRangeException for composite LVB images Apr 1, 2026
Copilot AI requested a review from jtschuster April 1, 2026 00:15
@jtschuster
Copy link
Copy Markdown
Member

/azp run runtime-coreclr crossgen2-composite

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
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

Fixes a crash in R2RDump when dumping composite Large Version Bubble (LVB) ReadyToRun images where manifest AssemblyRef entries outnumber actual component assembly headers.

Changes:

  • Add a bounds check in the composite component-assembly dump loop to stop iterating once assemblyIndex reaches _r2r.ReadyToRunAssemblyHeaders.Count, preventing ArgumentOutOfRangeException.

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

Labels

area-R2RDump-coreclr Ready-to-run image dump tool

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants