Hacker News new | ask | show | jobs
by Dowwie 605 days ago
Beware the risks of using NIFs with Elixir. They run in the same memory space as the BEAM and can crash not just the process but the entire BEAM. Granted, well-written, safe Rust could lower the chances of this happening, but you need to consider the risk.
1 comments

I believe that by using rustler[0] to build the bindings that shouldn't be possible. (at the very least that's stated in the readme.)

> Safety : The code you write in a Rust NIF should never be able to crash the BEAM.

I tried to find some documentation stating how it works but couldn't. I think they use a dirty scheduler, and catch panics at the boundaries or something? wasn't able to find a clear reference.

[0] https://github.com/rusterlium/rustler

I have no evidence of this but they may be liberally using catch_unwind: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html