Rustler precompiled segfaults in GH action

My typst package was recently updated, and I wanted to release a new version. I am using rustler precompiled to precompile the rust bindings to typst.

although the change to the code was minimal, the compilation for 2 targets fails with a segfault.

Compiling typst_nif v0.1.1 (/home/runner/work/typst/typst/native/typst_nif)
error: rustc interrupted by SIGSEGV, printing backtrace
...
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
error: could not compile `typst_nif` (lib)
Caused by:
  process didn't exit successfully: `rustc --crate-name typst_nif --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --emit=dep-info,link -C opt-level=3 -C lto --cfg 'feature="default"' --cfg 'feature="nif_version_2_15"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("default", "nif_version_2_15", "nif_version_2_16", "nif_version_2_17"))' -C metadata=684f38727e91bcf8 --out-dir /target/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -C linker=aarch64-linux-gnu-gcc -C strip=debuginfo -L dependency=/target/aarch64-unknown-linux-gnu/release/deps -L dependency=/target/release/deps --extern comemo=/target/aarch64-unknown-linux-gnu/release/deps/libcomemo-c278774ab144f6c8.rlib --extern rustler=/target/aarch64-unknown-linux-gnu/release/deps/librustler-c7f63b2eafc93dbf.rlib --extern tar=/target/aarch64-unknown-linux-gnu/release/deps/libtar-5166b6795e27638f.rlib --extern time=/target/aarch64-unknown-linux-
Done.

Full log

I followed the directions and added a step to the workflow to set the RUST_MIN_STACK env var,

- name: Set Rust stack size
  shell: bash
  run: |
    echo "RUST_MIN_STACK=16777216" >> $GITHUB_ENV

But alas this doesn’t make a difference.

Has anyone encountered something similar and know how to resolve this?

Thanks,

Herman

Reading throught the docs for rustler-precompiled, I added:

[build.env]
passthrough = [ "RUST_MIN_STACK" ]

to my Cargo.toml, but still the same error.

I would try the following:

  • Only one NIF version to try and isolate the problem;
  • Make sure you’re not using nightly Rust.

Hey @dimitarvp, what do you mean by your first point?

I meant those:

--cfg 'feature="nif_version_2_15"'

I would try with the newest first.

Oh I see, this is handled by (I think) by the nif: ["2.15"] in the workflow. I updated it to include 2.17, but the same 2 fail with the same error.

I just tried changing from Ubuntu 22.04 → 24.04 but that doesn’t help either.

Hm, which Rust version?

rustc 1.87.0

Hmm, when I look at the previous release’s actions, they were using rustc 1.86.0.
But I don’t know if I can specify that anywhere.

I changed the workflow to use:

- name: Install Rust
  uses: dtolnay/rust-toolchain@stable
  with:
    toolchain: 1.86.0  # Specify your desired Rust version
    targets: ${{ matrix.job.target }}

instead of

- name: Add target
  shell: bash
  run: |
    rustup target add ${{ matrix.job.target }}

Now it uses rust 1.86 and that works!

Thanks for the assist!

Whoa, that would be pretty nasty if they broke it in Rust 1.87. :confused:

Glad you fixed it!