Skip to content

Add test for IL manipulation issue on Mono runtime - #233

Draft
monomod[bot] wants to merge 13 commits into
reorganizefrom
ai/issue230
Draft

monomod[bot] wants to merge 13 commits into
reorganizefrom
ai/issue230

Conversation

@monomod

@monomod monomod Bot commented May 26, 2025

Copy link
Copy Markdown
Contributor

Test for #230

  • Reproduces the issue with IL manipulation on Mono runtime
  • Ensures multiple ILHook applications do not throw InvalidProgramException
  • Checks that IL cursor manipulation works correctly across multiple hooks

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

Total Skipped Passed Failed
Unique 282 0 280 2
Total 25649 182 25462 5

Failing runs

❌ MonoMod.UnitTest.AssemblyLoadContextHookTest.TestAssemblyLoadContextHook

Class Name: MonoMod.UnitTest.AssemblyLoadContextHookTest | Method Name: TestAssemblyLoadContextHook | This test is sometimes failing.

Failures present in
  • test-results .NET Core 3.0 x64 on MacOS 14/TestResults/testresults.macos-14.3.0.x64.trx
❌ test-results .NET Core 3.0 x64 on MacOS 14/TestResults/testresults.macos-14.3.0.x64.trx MonoMod.UnitTest.AssemblyLoadContextHookTest.TestAssemblyLoadContextHook

Took 00:00:00.7048711

Exception message:

Assert.NotNull() Failure

Stack trace:

   at MonoMod.UnitTest.AssemblyLoadContextHookTest.TestStaticMethod(AssemblyLoadContextHookTest loader, Int32 id1, Int32 id2) in /_/src/MonoMod.UnitTest/RuntimeDetour/AssemblyLoadContextHookTest.cs:line 225

Test Standard Output has been omitted because it is too long.

❌ MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed

Class Name: MonoMod.UnitTest.Github.Issue230 | Method Name: ILHookOnMonoShouldSucceed | This test is sometimes failing.

Failures present in
  • test-results System Mono on Linux musl/testresults.ubuntu-latest.sysmono.x64.xml
  • test-results System Mono on Linux/testresults.ubuntu-latest.sysmono.x64.xml
  • test-results System Mono on MacOS 13/testresults.macos-13.sysmono.x64.xml
  • test-results System Mono on MacOS 14/testresults.macos-14.sysmono.arm64.xml
❌ test-results System Mono on Linux musl/testresults.ubuntu-latest.sysmono.x64.xml MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed

Took 00:00:00.0379382

Exception message:

System.InvalidProgramException : Invalid IL code in (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:DMD<DMD<>?-1388632246::MonoMod.UnitTest.Github.Issue230::Original> (): IL_0078: call      0x0000001d


Stack trace:

  at (wrapper managed-to-native) System.RuntimeMethodHandle.GetFunctionPointer(intptr)
  at System.RuntimeMethodHandle.GetFunctionPointer () [0x00000] in <19a0624062f54e9b8fd511dada6aca82>:0 
  at MonoMod.Core.Platforms.Runtimes.MonoRuntime.Compile (System.Reflection.MethodBase method) [0x00008] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.Core.Platforms.PlatformTriple.Compile (System.Reflection.MethodBase method) [0x00047] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.UpdateEndOfChain () [0x000e1] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.AddILHook (MonoMod.RuntimeDetour.DetourManager+SingleILHookState ilhook, System.Boolean takeLock) [0x000e9] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook.Apply () [0x00052] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase method, MonoMod.Cil.ILContext+Manipulator manipulator, MonoMod.Core.IDetourFactory factory, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00098] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config) [0x00000] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed () [0x00052] in <3db4d3f5ab8b4a82a35defd514420161>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <19a0624062f54e9b8fd511dada6aca82>:0 
❌ test-results System Mono on Linux/testresults.ubuntu-latest.sysmono.x64.xml MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed

Took 00:00:00.4540322

Exception message:

System.InvalidProgramException : Invalid IL code in (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:DMD<DMD<>?61360601::MonoMod.UnitTest.Github.Issue230::Original> (): IL_0078: call      0x0000001d


Stack trace:

  at (wrapper managed-to-native) System.RuntimeMethodHandle.GetFunctionPointer(intptr)
  at System.RuntimeMethodHandle.GetFunctionPointer () [0x00000] in <12b418a7818c4ca0893feeaaf67f1e7f>:0 
  at MonoMod.Core.Platforms.Runtimes.MonoRuntime.Compile (System.Reflection.MethodBase method) [0x00008] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.Core.Platforms.PlatformTriple.Compile (System.Reflection.MethodBase method) [0x00047] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.UpdateEndOfChain () [0x000e1] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.AddILHook (MonoMod.RuntimeDetour.DetourManager+SingleILHookState ilhook, System.Boolean takeLock) [0x000e9] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook.Apply () [0x00052] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase method, MonoMod.Cil.ILContext+Manipulator manipulator, MonoMod.Core.IDetourFactory factory, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00098] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config) [0x00000] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed () [0x00052] in <3db4d3f5ab8b4a82a35defd514420161>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007c] in <12b418a7818c4ca0893feeaaf67f1e7f>:0 
❌ test-results System Mono on MacOS 13/testresults.macos-13.sysmono.x64.xml MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed

Took 00:00:00.0627008

Exception message:

System.InvalidProgramException : Invalid IL code in (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:DMD<DMD<>?1110434349::MonoMod.UnitTest.Github.Issue230::Original> (): IL_0078: call      0x0000001d


Stack trace:

  at (wrapper managed-to-native) System.RuntimeMethodHandle.GetFunctionPointer(intptr)
  at System.RuntimeMethodHandle.GetFunctionPointer () [0x00000] in <bab7d1a00376483b944db50cdc31e41d>:0 
  at MonoMod.Core.Platforms.Runtimes.MonoRuntime.Compile (System.Reflection.MethodBase method) [0x00008] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.Core.Platforms.PlatformTriple.Compile (System.Reflection.MethodBase method) [0x00047] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.UpdateEndOfChain () [0x000e1] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.AddILHook (MonoMod.RuntimeDetour.DetourManager+SingleILHookState ilhook, System.Boolean takeLock) [0x000e9] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook.Apply () [0x00052] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase method, MonoMod.Cil.ILContext+Manipulator manipulator, MonoMod.Core.IDetourFactory factory, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00098] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config) [0x00000] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed () [0x00052] in <3db4d3f5ab8b4a82a35defd514420161>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <bab7d1a00376483b944db50cdc31e41d>:0 
❌ test-results System Mono on MacOS 14/testresults.macos-14.sysmono.arm64.xml MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed

Took 00:00:01.7262091

Exception message:

System.InvalidProgramException : Invalid IL code in (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:DMD<DMD<>?843181652::MonoMod.UnitTest.Github.Issue230::Original> (): IL_0078: call      0x0000001d


Stack trace:

  at (wrapper managed-to-native) System.RuntimeMethodHandle.GetFunctionPointer(intptr)
  at System.RuntimeMethodHandle.GetFunctionPointer () [0x00000] in <bab7d1a00376483b944db50cdc31e41d>:0 
  at MonoMod.Core.Platforms.Runtimes.MonoRuntime.Compile (System.Reflection.MethodBase method) [0x00008] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.Core.Platforms.PlatformTriple.Compile (System.Reflection.MethodBase method) [0x00047] in <efbed17d983b4c86bf3b7ec49edb0244>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.UpdateEndOfChain () [0x000e1] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.DetourManager+ManagedDetourState.AddILHook (MonoMod.RuntimeDetour.DetourManager+SingleILHookState ilhook, System.Boolean takeLock) [0x000e9] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook.Apply () [0x00052] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase method, MonoMod.Cil.ILContext+Manipulator manipulator, MonoMod.Core.IDetourFactory factory, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00098] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config, System.Boolean applyByDefault) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip, MonoMod.RuntimeDetour.DetourConfig config) [0x00000] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.RuntimeDetour.ILHook..ctor (System.Reflection.MethodBase source, MonoMod.Cil.ILContext+Manipulator manip) [0x00008] in <39d68a08e45c49a9876e55db77e66023>:0 
  at MonoMod.UnitTest.Github.Issue230.ILHookOnMonoShouldSucceed () [0x00052] in <3db4d3f5ab8b4a82a35defd514420161>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <bab7d1a00376483b944db50cdc31e41d>:0 

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.

2 participants