Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix assertion failure in ILDasm with -METADATA=RAW flag - #122876

#122876
Merged
AaronRobinsonMSFT merged 3 commits into
maindotnet/runtime:mainfrom
copilot/fix-assert-ildasm-metadata-rawdotnet/runtime:copilot/fix-assert-ildasm-metadata-rawCopy head branch name to clipboard
Jan 5, 2026
Merged

Fix assertion failure in ILDasm with -METADATA=RAW flag#122876
AaronRobinsonMSFT merged 3 commits into
maindotnet/runtime:mainfrom
copilot/fix-assert-ildasm-metadata-rawdotnet/runtime:copilot/fix-assert-ildasm-metadata-rawCopy head branch name to clipboard

Conversation

Copilot AI commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Description

ILDasm crashes with assertion failure when invoked with -METADATA=RAW:

ASSERT FAILED
    Expression: ARRAY_SIZE(g_szMapElementType) == ELEMENT_TYPE_MAX
    Location:   line 256 in src/coreclr/tools/metainfo/mdinfo.cpp

The g_szMapElementType and g_szMapUndecorateType arrays had 34 elements but ELEMENT_TYPE_MAX is 0x23 (35). Missing entry: ELEMENT_TYPE_CMOD_INTERNAL at index 0x22.

Added "CMOD_INTERNAL" to both arrays in mdinfo.cpp.

Customer Impact

ILDasm with -METADATA=RAW flag fails immediately on any assembly. Blocks metadata inspection workflows.

Regression

Yes. ELEMENT_TYPE_CMOD_INTERNAL was added to corhdr.h but corresponding array entries were not updated.

Testing

  • Built CoreCLR successfully
  • Verified ILDasm with -METADATA=RAW completes without assertion on test assembly

Risk

Low. Two-line fix adds missing array element to match enum definition. No logic changes.

Original prompt

This section details on the original issue you should resolve

<issue_title>Assert when passing -METADATA=RAW to ILDasm.</issue_title>
<issue_description>runtime/artifacts/bin/coreclr/osx.arm64.Debug/ildasm -ALL -METADATA=RAW Test.dll > out.txt
ASSERT FAILED
Expression: ARRAY_SIZE(g_szMapElementType) == ELEMENT_TYPE_MAX
Location: line 256 in .../runtime/src/coreclr/ildasm/../tools/metainfo/mdinfo.cpp
Function: MDInfo
Process: 36920
zsh: trace trap runtime/artifacts/bin/coreclr/osx.arm64.Debug/ildasm -ALL -METADATA=RAW</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 5, 2026 15:14
Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 11.0.0 milestone Jan 5, 2026
@AaronRobinsonMSFT
AaronRobinsonMSFT marked this pull request as ready for review January 5, 2026 15:21
Copilot AI review requested due to automatic review settings January 5, 2026 15:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 assertion failure that occurs when running ILDasm with the -METADATA=RAW flag. The root cause was a size mismatch between the g_szMapElementType and g_szMapUndecorateType arrays (which had 34 elements) and the expected size ELEMENT_TYPE_MAX (which is 0x23 or 35 decimal). The missing element was ELEMENT_TYPE_CMOD_INTERNAL at index 0x22.

Key changes:

  • Added ELEMENT_TYPE_CMOD_INTERNAL entry to both mapping arrays in mdinfo.cpp to match the complete CorElementType enum
  • Modified assertion format in pal_assert.h to reorder filename and line number display

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/tools/metainfo/mdinfo.cpp Adds missing "CMOD_INTERNAL" entry at index 0x22 to both g_szMapElementType and g_szMapUndecorateType arrays, fixing the array size to match ELEMENT_TYPE_MAX (35 elements)
src/coreclr/pal/inc/pal_assert.h Reorders __FILE__ and __LINE__ parameters in assertion output format from "line %d in %s" to "%s:%d"

Comment thread src/coreclr/pal/inc/pal_assert.h
Copilot AI changed the title [WIP] Fix assert when passing -METADATA=RAW to ILDasm Fix assertion failure in ILDasm with -METADATA=RAW flag Jan 5, 2026
Copilot AI requested a review from AaronRobinsonMSFT January 5, 2026 15:28
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

@jkoritzinsky Looks like we missed updating ILDasm when adding ELEMENT_TYPE_CMOD_INTERNAL in #106424.

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

/ba-g Unrelated

@AaronRobinsonMSFT
AaronRobinsonMSFT merged commit 27a5c7d into main Jan 5, 2026
105 of 109 checks passed
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the copilot/fix-assert-ildasm-metadata-raw branch January 5, 2026 18:16
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assert when passing -METADATA=RAW to ILDasm.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.