I’ve just started porting some code to OCaml and have written ~1kLOC of vanilla OCaml code. The only things I’m using are PPX deriving show and ord. When I run my little program I get:
./run.sh: line 1: 1896 Segmentation fault: 11
I’m on an M2 Mac so I fire up lldb and it says:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x9)
frame #0: 0x000000010001169c w.exe`camlDune__exe__P__anon_fn$5bp$2eml$3a35$2c50$2d$2d75$5d_522 + 132
w.exe`camlDune__exe__P__anon_fn$5bp$2eml$3a35$2c50$2d$2d75$5d_522:
-> 0x10001169c <+132>: ldr x1, [x22, #0x8]
0x1000116a0 <+136>: ldr x0, [x22]
0x1000116a4 <+140>: bl 0x100011588 ; camlDune__exe__P__anon_fn$5bp$2eml$3a35$2c51$2d$2d68$5d_599
0x1000116a8 <+144>: orr x0, xzr, #0x3
I’m struggling to read that but it looks like it is loading some data from an invalid location. Just in case it is a stack overflow I tried a stack trace:
(lldb) thread backtrace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x9)
* frame #0: 0x000000010001169c w.exe`camlDune__exe__P__anon_fn$5bp$2eml$3a35$2c50$2d$2d75$5d_522 + 132
frame #1: 0x000000010016fc40 w.exe`camlStdlib__Array__fold_left_625 + 136
frame #2: 0x0000000100010398 w.exe`camlDune__exe__P__anon_fn_496 + 128
frame #3: 0x00000001001ab674 w.exe`camlStdlib__Format__k_7979 + 28
frame #4: 0x0000000100010918 w.exe`camlDune__exe__P__parse_453 + 16
frame #5: 0x000000010019bcc0 w.exe`camlStdlib__Fun__protect_85 + 96
frame #6: 0x00000001000081d8 w.exe`camlDune__exe__Language__check_141 + 80
frame #7: 0x0000000100006bf4 w.exe`camlDune__exe__Wiki__code_begin + 188
frame #8: 0x00000001000034dc w.exe`caml_program + 4716
frame #9: 0x00000001001feb0c w.exe`caml_start_program + 104
frame #10: 0x00000001001d9058 w.exe`caml_startup_common(argv=0x00000001082562a8, pooling=<unavailable>) at startup_nat.c:160:9 [opt]
frame #11: 0x00000001001d90cc w.exe`caml_main [inlined] caml_startup_exn(argv=<unavailable>) at startup_nat.c:167:10 [opt]
frame #12: 0x00000001001d90c4 w.exe`caml_main [inlined] caml_startup(argv=<unavailable>) at startup_nat.c:172:15 [opt]
frame #13: 0x00000001001d90c4 w.exe`caml_main(argv=<unavailable>) at startup_nat.c:179:3 [opt]
frame #14: 0x00000001001d912c w.exe`main(argc=<unavailable>, argv=<unavailable>) at main.c:37:3 [opt]
frame #15: 0x00000001b1657e50 dyld`start + 2544
Anyone know what’s going on or how best to proceed?
I’m using OCaml 4.14.1 BTW.