Platform/windows/uum-62035 to unity-main #2003
Merged
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.
Fix marshaling/interop code emitting ldloc 65535 instruction when calling method on a COM interface. This happened due to unitialized local variable (gc_safe_transition_builder.coop_cominterop_fnptr) getting loaded when "need_gc_safe" is false. This caused the JIT to throw an InvalidOperationException. This fixes case UUM-62035. This bug was indirectly introduced by a previous pull request, which optimized interop call performance and made us take another code path which turned out not to work with COM interop: #1753.
Reviewers: please consider these questions as well! ❤️
Release notes
Fixed UUM-62035 @zilys
Mono: Fixed InvalidProgramException (Invalid IL code in (wrapper managed-to-native) : IL_0004: ldloc 65535)
getting thrown when calling COM interop methods,
Backports
Unity 2023.3 and Unity 2023.2.
Unity repository changes
I added a test for this change on this branch: https://github.cds.internal.unity3d.com/unity/unity/commits/platform/windows/uum-62035. Preferably this test gets merged to trunk together with this bugfix.