thierry-martinez / metapp

Meta-preprocessor for OCaml
BSD 3-Clause "New" or "Revised" License
76 stars 8 forks source link

Unable to build with OCaml 4.14, receive SIGBUS #12

Open zbaylin opened 6 months ago

zbaylin commented 6 months ago

When trying to build metapp (both master and 0.4.4), I'm receiving a SIGBUS during (what I presume is) the metapp.ppx step of the process.

This is on macOS 14.2.1 and XCode 15.1.

Steps to reproduce

When doing the above, I get the following output:

File "metapp/dune", line 3, characters 14-46:
3 |   (preprocess (pps ppxlib.metaquot metapp.ppx))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Command [1] got signal BUS:
$ (cd _build/default && .ppx/f04423e293bc7238bf6fa2027578cb58/ppx.exe --cookie 'library-name="metapp"' -o metapp/metapp.pp.ml --impl metapp/metapp.ml -corrected-suffix .ppx-corrected -diff-cmd - -dump-ast)
zbaylin commented 6 months ago

Interestingly, this seems like it might be a bug in ppxlib. The backtrace looks like:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=257, address=0x7a2f73726573552f)
  * frame #0: 0x000073726573552f
    frame #1: 0x0000000100f4bbd4 metapp_version_info.cmxs`caml_apply11 + 124
    frame #2: 0x0000000100111288 ppx.exe`camlPpxlib_ast__Ast_helper_lite__code_begin + 144
    frame #3: 0x000000010050af74 ppx.exe`caml_callback [inlined] caml_callback_exn(closure=<unavailable>, arg=<unavailable>) at callback.c:111:10 [opt]
    frame #4: 0x000000010050af5c ppx.exe`caml_callback(closure=<unavailable>, arg=0) at callback.c:165:34 [opt]
    frame #5: 0x000000010050fd98 ppx.exe`caml_natdynlink_run(handle_v=<unavailable>, symbol=<unavailable>) at dynlink_nat.c:128:36 [opt]
    frame #6: 0x00000001005154e8 ppx.exe`caml_call_gc + 352
zbaylin commented 6 months ago

Okay not as sure about that anymore, it might have just been a faulty llvm trace -- caml_call_gc + 352 doesn't seem to point anywhere useful. The natdynlink stuff though does seem relevant, since I noticed https://github.com/thierry-martinez/metapp/blob/master/ppx/findlib_for_ppx.ml has a decent amount of Dynlink stuff in it. I wonder if something in there is the culprit? I'll do some more research.

jonahbeckford commented 4 months ago

I had the same error with OCaml 4.14.0 + 4.14.1 on macOS arm64 using the following compilers:

In an odd coincidence, I ran into an error at the same location very recently in https://github.com/ocaml-ppx/ppxlib/issues/466 (section "Initial Attempt. OUTDATED and FIXED"). It was almost the same except then I did not receive a SIGBUS, but I was using bytecode so that wasn't surprising. And that older problem had an easy root cause.