# Hashlink seg fault MacOS (Apple Silicon)

**URL:** <https://community.haxe.org/t/hashlink-seg-fault-macos-apple-silicon/4225>\
**Category:** Haxe\
**Created:** [April 28, 2024, 5:31am UTC](https://community.haxe.org/t/hashlink-seg-fault-macos-apple-silicon/4225 "2024-04-28T05:31:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wintermute](https://avatars.discourse-cdn.com/v2/letter/w/e19b73/32.png) [@wintermute](https://community.haxe.org/u/wintermute)\
**Post date:** [April 28, 2024, 5:31am UTC](https://community.haxe.org/t/hashlink-seg-fault-macos-apple-silicon/4225/1 "2024-04-28T05:31:51Z")

</div>

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

Running with no input is fine

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

```

Running with bytecode seg faults

```haxe
% 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:

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

```

---

<div class="post-metadata">

**Author:** ![neimanpinchas](https://community.haxe.org/user_avatar/community.haxe.org/neimanpinchas/32/2348_2.png) [@neimanpinchas](https://community.haxe.org/u/neimanpinchas)\
**Post date:** [May 1, 2024, 4:58pm UTC](https://community.haxe.org/t/hashlink-seg-fault-macos-apple-silicon/4225/2 "2024-05-01T16:58:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wintermute](https://avatars.discourse-cdn.com/v2/letter/w/e19b73/32.png) [@wintermute](https://community.haxe.org/u/wintermute)\
**Post date:** [May 15, 2024, 7:12pm UTC](https://community.haxe.org/t/hashlink-seg-fault-macos-apple-silicon/4225/3 "2024-05-15T19:12:27Z")

</div>

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

```haxe
(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

```

---

<div class="post-metadata">

**Author:** ![okaybmd](https://community.haxe.org/user_avatar/community.haxe.org/okaybmd/32/2355_2.png) [@okaybmd](https://community.haxe.org/u/okaybmd)\
**Post date:** [June 3, 2024, 2:21pm UTC](https://community.haxe.org/t/hashlink-seg-fault-macos-apple-silicon/4225/4 "2024-06-03T14:21:12Z")

</div>

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):

> [@Compiling HashLink on macOS Apple Silicon](https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150/5):
>
> Hi! I also managed to build hl for my Mac: MacBook Air with M1 processor, macOS Sonoma OS (14.5). I’m leaving here for posterity, full steps, compiled from other sources as well (since those needed to be adjusted for Sonoma anyway). Please note that this setup works after I already have a regular version of homebrew installed, and a hl compiled (that does NOT work), however, this way is easier because you don’t need to make any edits to flags (as @cpimhoff is saying above). Open a NEW termin…
