rm-rf-etc

rm-rf-etc

I’m having trouble building with rustler. I reviewed the open issues on the rustler repo and it looks like it hasn’t been updated to support newer OTP versions 22 and 23. I have tried compiling the following two projects:
https://github.com/discord/sorted_set_nif
https://github.com/rusterlium/NifIo

In the first project, I found an open issue where someone indicates that it compiles successfully with OTP 21.1.1, so that’s what I’ve downgraded to. I’m using kerl to manage my erlang version, and my elixir version is on 1.11.1. Here is the error I’m getting when trying to build sorted_set_nif:

RUST_BACKTRACE=full mix compile
Compiling NIF crate :sorted_set (native/sorted_set_nif)...
warning: variable does not need to be mutable
   --> src/supported_term.rs:130:25
    |
130 |                     let mut idx = 0;
    |                         ----^^^
    |                         |
    |                         help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
   --> src/supported_term.rs:150:25
    |
150 |                     let mut idx = 0;
    |                         ----^^^
    |                         |
    |                         help: remove this `mut`

warning: 2 warnings emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
Compiling 3 files (.ex)
thread '<unnamed>' panicked at 'attempted to leave type `erlang_nif_sys::ErlNifResourceFlags` uninitialized, which is invalid', /Users/rob/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/mem/mod.rs:659:9
stack backtrace:
   0:         0x5740b674 - std::backtrace_rs::backtrace::libunwind::trace::h3440e89bdeed3ddf
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:         0x5740b674 - std::backtrace_rs::backtrace::trace_unsynchronized::hfa68bcc7baf06ad7
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:         0x5740b674 - std::sys_common::backtrace::_print_fmt::h483e161a2ffbfba4
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/sys_common/backtrace.rs:67:5
   3:         0x5740b674 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h34f76b2ca42fab41
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/sys_common/backtrace.rs:46:22
   4:         0x5741e69d - core::fmt::write::h8f13d857463c51c1
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/fmt/mod.rs:1078:17
   5:         0x574095c6 - std::io::Write::write_fmt::h0a6214ccb1a8468b
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/io/mod.rs:1517:15
   6:         0x5740d029 - std::sys_common::backtrace::_print::h7f3525175df798e8
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/sys_common/backtrace.rs:49:5
   7:         0x5740d029 - std::sys_common::backtrace::print::hf68eec1a3c535c32
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/sys_common/backtrace.rs:36:9
   8:         0x5740d029 - std::panicking::default_hook::{{closure}}::hb14d90e928578cc7
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:208:50
   9:         0x5740cbb0 - std::panicking::default_hook::h460969f1dc8f738d
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:225:9
  10:         0x5740d6ab - std::panicking::rust_panic_with_hook::h28bf9d6c3916221e
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:591:17
  11:         0x5740d1a9 - std::panicking::begin_panic_handler::{{closure}}::h99569328be4adae9
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:495:13
  12:         0x5740bb18 - std::sys_common::backtrace::__rust_end_short_backtrace::h9a7e5cc6475b496b
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/sys_common/backtrace.rs:141:18
  13:         0x5740d13a - rust_begin_unwind
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
  14:         0x574243df - core::panicking::panic_fmt::h65997884a2662b8c
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
  15:         0x57424337 - core::panicking::panic::h2ca2e9d2b0a1f2bf
                               at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:50:5
  16:         0x573e72f5 - core::mem::uninitialized::hd3f8dde2b112491b
                               at /Users/rob/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/mem/mod.rs:659:9
  17:         0x573e72f5 - rustler::wrapper::resource::open_resource_type::had589574171911d3
                               at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/rustler-0.18.0/src/wrapper/resource.rs:28:43
  18:         0x573d9fc6 - rustler::resource::open_struct_resource_type::hcfbbf1a0c976f53a
  19:         0x573c6722 - sorted_set_nif::load::hf2bb44c69ec6337e
  20:         0x573e476d - rustler::codegen_runtime::handle_nif_init_call::h2dd8ea321b7ab28a
                               at /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/rustler-0.18.0/src/codegen_runtime.rs:66:12
  21:         0x573cb0c3 - sorted_set_nif::nif_init::nif_load::h9fa949fb4c4a8871
  22:         0x12d83f04 - load_nif_2
                               at /Users/rob/.kerl/builds/21.1.1/otp_src_21.1.1/erts/emulator/beam/erl_nif.c:4205:16
  23:         0x12e1f45d - process_main
                               at /Users/rob/.kerl/builds/21.1.1/otp_src_21.1.1/erts/emulator/x86_64-apple-darwin20.1.0/opt/smp/beam_cold.h:59:24
  24:         0x12e2ea04 - sched_thread_func
                               at /Users/rob/.kerl/builds/21.1.1/otp_src_21.1.1/erts/emulator/beam/erl_process.c:8332:5
  25:         0x12e1879a - thr_wrapper
                               at /Users/rob/.kerl/builds/21.1.1/otp_src_21.1.1/erts/lib_src/pthread/ethread.c:118:25
  26:     0x7fff2038e950 - __pthread_start
fatal runtime error: failed to initiate panic, error 5
Abort trap: 6

Regarding the rusterlium example project, it seems to build and run successfully, but logs 17 warnings, and these give me the impression that the example code is not up to date with rustler. One such warning:

warning: use of deprecated macro `::rustler::rustler_export_nifs`: Please use `rustler::init!` instead.
  --> src/lib.rs:51:1
   |
51 | / rustler_export_nifs!(
52 | |     "Elixir.NifIo.Native",
53 | |     [("open", 1, open_file),
54 | |      ("read_until", 2, read_until)],
55 | |     Some(on_load)
56 | | );
   | |__^
   |
   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

I’m primarily hoping someone will be able to help me understand what this error means and how to resolve it:

attempted to leave type `erlang_nif_sys::ErlNifResourceFlags` uninitialized, which is invalid

Showing Posts 1 to 8

dimitarvp

dimitarvp

Take a look at the partially updated README.md in the GitHub repo after switching to the rustler-0.22.0-rc.0 tag.

I can help you with Rustler; I am still working on a project that relies heavily on it and had to discover some pain points by myself.

rm-rf-etc

rm-rf-etc OP

Hi @dimitarvp, and thanks. Looking forward to getting this working.

The readme in master is identical to the readme in tag rustler-0.22.0-rc.0. Maybe the changes are somewhere else?

rm-rf-etc

rm-rf-etc OP

Did you mean this readme → Rustler — Rustler Mix v0.22.0-rc.0 ? I found it just now, it does look different from what I see on github → GitHub - rusterlium/rustler at rustler-0.22.0-rc.0 · GitHub

Am I looking at the wrong repo?

rm-rf-etc

rm-rf-etc OP

Okay, build now works. My issue was that I missed a step, I didn’t add :compilers and :rustler_crates to my mix.exs file. I also suspect the name I provided for module and library may have not matched with the config and use directive, in my previous attempts. I’ve pushed a tutorial here to help anyone else who maybe runs into the same issue: GitHub - rm-rf-etc/rustler_tutorial: Shows how to get your new Elixir Rust NIF to build · GitHub

However, I haven’t yet tried building the sorted_set_nif, so I still don’t know why this one doesn’t build, but for my concerns, I don’t think I actually need this to build. I was going to use it for reference, but so long as I can get a blank NIF project to build, that should be fine.

zeroexcuses

zeroexcuses

@rm-rf-etc : Thanks for writing the tutorial. I was running into similar rustler problems.

dimitarvp

dimitarvp

You got away easily. :smiley:

@zeroexcuses Sadly Rustler is not maintained for a while (at least not in terms of a release) but there are fixes. Overall I’ve been very happy with it even with it looking kind of abandoned.

zookzook

zookzook

I created a PR 17 to update SortedSet to rustler 0.22, so you can use the SortedSet in Elixir 1.12.x and OTP 24. I leave this comment here, maybe someone wants to use the package in Elixir 1.12.x and OTP 24 and is searching for some hints.

dimitarvp

dimitarvp

Yes, there are people like that (me). Thanks! :heart:

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews