Hashlink seg fault MacOS (Apple Silicon)

I’ve tried both brew and built from source and both have identical results

Running with no input is fine

 % hl
HL/JIT 1.14.0 (c)2015-2023 Haxe Foundation
  Usage : hl [--debug <port>] [--debug-wait] <file>

Running with bytecode seg faults

% haxe --hl hello.hl --main Main
% hl hello.hl 
zsh: segmentation fault  hl hello.hl

The code is the simple Hello World example on the hashlink website.
Edit - posting the code for posterity:

/**
    Multi-line comments for documentation.
**/
class Main {
    static public function main():Void {
        // Single line comment
        trace("Hello World");
    }
}
2 Likes

More a comment than an answer, I do not know apple and not an expert in low level, but in my cases I was able to guess and identify hashlink segfaults by running the program under gdb
like gdb hl
then at the 2nd prompt you type run hello.hl
wait for the segfault, you will get some kind of stacktrace.

Ran through lldb and did a backtrace. Looks like the segfault is related to memmove in jit code - is there anyway to disable jit?

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffff)
  * frame #0: 0x000000018c5ab1ec libsystem_platform.dylib`_platform_memmove + 76
    frame #1: 0x000000010001051c hl`hl_jit_code + 120
    frame #2: 0x0000000100013d60 hl`hl_module_init + 440
    frame #3: 0x000000010001313c hl`main + 572
    frame #4: 0x000000018c1f20e0 dyld`start + 2360

I got the exact same issue, ran lldb and came to a similar result, it also said

EXC_BAD_ACCESS (code=1, address=0xffffffffffffffff)

but different info on next line (and no jit info). It turns out, there was NOT related to jit at all. To fix this, you need to compile HashLink again, using the Intel architecture. Full steps here (works great for your current setup, since you already have Homebrew and HL versions installed, even if they don’t work as expected, i.e. you will install intel versions on the same machine alongside the current ones):