Skip to content

on mono on Rosetta environment, crashes with SIGSEGV #517

@anatawa12

Description

@anatawa12

IMPORTANT: Do NOT use this form to send support questions. If you send things like "How do I do X" or "It does not patch Y" your submission will be closed and you will be forwarded to the official Harmony Discord channel anyway.

OFFICIAL DISCORD: https://discord.gg/xXgghXR

If you think you found a bug in Harmony please use the following to format:


Describe the bug
on mono on Rosetta environment, crashes with SIGSEGV

To Reproduce
Steps to reproduce the behavior:

Any trial to patch any method with Harmony for mono on Rosetta will cause SIGSEGV.
This happens in constrcutor of DetourRuntimeMonoPlatform.

error message

=================================================================
        Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
        Native stacktrace:
=================================================================
        0x102a4c639 - /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono-sgen64 : mono_dump_native_crash_info
        0x1029e43ee - /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono-sgen64 : mono_handle_native_crash
        0x102a467b6 - /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono-sgen64 : altstack_handle_and_restore
        0x102c2b996 - /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono-sgen64 : mono_thread_info_is_current

=================================================================
        Telemetry Dumper:
=================================================================
Pkilling 0x13048594432x from 0x8640361152x
Entering thread summarizer pause from 0x8640361152x
Finished thread summarizer pause from 0x8640361152x.
* Assertion: should not be reached at mini-exceptions.c:452

Expected behavior
No SIGSEGV

Screenshots / Code

using HarmonyLib;
public class test {
    public static void Main(string[] args) {
        var method = typeof(test).GetMethod("Test");

        Memory.GetMethodStart(method, out var exception);

        if (exception != null) throw exception;
    }

    public static void Test() {
    }
}

Runtime environment (please complete the following information):

  • OS: macOS 13.0 (22A380)
  • .NET version test code: Mono JIT compiler version 6.12.0.182, found: Unity 2019.4.31f1
  • Harmony version 2.2.2.2
  • Name of game or host application test code: nothing, found: UnityEditor

Additional context
I've reported & created pull request of this problem on MonoMod.Common module.

The following code will work as workaround. https://github.com/anatawa12/edit-unity-editor-native-method-test/blob/88a5f66adfd7deba4e3ee2768d1fe98d093c1d4a/Test.cs#L96-L171

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions