Repository navigation
Fix: TryGenerateStructMarshallingMethod asserts on non-struct T in StructureMarshaler<T> - #130855
Merged
Merged
Conversation
|
Azure Pipelines: 15 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
…struct types Co-authored-by: jkotas <[email protected]>
Copilot
AI
changed the title
[WIP] Fix StructureMarshaler to guard against non-struct type arguments
Fix: TryGenerateStructMarshallingMethod asserts on non-struct T in StructureMarshaler<T>
Jul 16, 2026
jkotas
marked this pull request as ready for review
July 17, 2026 04:10
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens CoreCLR’s struct marshalling stub generation so that invalid StructureMarshaler<T> instantiations with a reference-type T no longer trigger a VM debug assertion during intrinsic/transient IL generation (e.g., when RuntimeHelpers.PrepareMethod is used on such an instantiation).
Changes:
- Replace a debug-only
_ASSERTE(pStructMT->IsValueType())with a runtime guard that returnsfalsewhenTis not a value type. - Ensure the JIT falls back to the normal managed IL body for these invalid instantiations instead of attempting to generate struct marshalling IL (and asserting).
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
AaronRobinsonMSFT
approved these changes
Jul 17, 2026
Member
|
/ba-g Failure is #130961 |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TryGenerateStructMarshallingMethodcontained_ASSERTE(pStructMT->IsValueType())which crashes the process in debug builds when tools likejit-dasm-pmicallRuntimeHelpers.PrepareMethodon aStructureMarshaler<object>(or any non-struct) instantiation.Replace the assert with an early
return false, causing the JIT to fall back to the default C# implementation rather than crashing.Fixes #129649