Skip to content

Conversation

@TautvydasZilys
Copy link

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.

  • Should this pull request have release notes?
    • Yes
    • No
  • Do these changes need to be back ported?
    • Yes
    • No
  • Do these changes need to be upstreamed to mono/mono or dotnet/runtime repositories?
    • Yes
    • No
    • I don't know - do you think we should?

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.

…ling 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 (case UUM-62035).
@unity-cla-assistant
Copy link
Collaborator

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@TautvydasZilys
Copy link
Author

Hey folks, what's the current process of:

  1. Making sure that the change makes it to trunk together with the playmode test I added in the Unity repository branch?
  2. This change is backported?

@UnityAlex
Copy link
Collaborator

Hey folks, what's the current process of:

1. Making sure that the change makes it to trunk together with the playmode test I added in the Unity repository branch?

2. This change is backported?

@jhcdunity3d Has been in charge of synching the zips to Unity. He can get you set up.

@TautvydasZilys TautvydasZilys merged commit c6f10bf into unity-main Mar 21, 2024
@TautvydasZilys TautvydasZilys deleted the platform/windows/uum-62035 branch March 21, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants