Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

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.

@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
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 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"

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
@AaronRobinsonMSFT
Copy link
Member

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

@AaronRobinsonMSFT
Copy link
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
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.

Assert when passing -METADATA=RAW to ILDasm.

3 participants