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

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews