[erlang-questions] Erlang VM in Rust

Attila Rajmund Nohl attila.r.nohl@REDACTED
Fri Sep 22 12:42:58 CEST 2017


2017-09-21 19:12 GMT+02:00 Frank Muller <frank.muller.erl@REDACTED>:
[...]
> 2. Why simply not simply learn how to better code our NIF/Drivers instead? C
> was/is my main programming language for many years now, and I didn't have
> any major issue with it (medium to large projects) in production environment
> so far. Maybe I'm just lucky, maybe not.

Probably you're lucky. Last time I worked on a C code, there was a
mysterious (but thankfully reproducable) crash. According to the core
file the process tried to follow a null pointer variable, but if I
checked the memory where the variable was, it was not null. I went
down to the assembly code and the contents of the registers, there was
nothing that explained the crash. The variable was in a structure that
was initialized at startup, then never written. In final despair I
moved the initialization from runtime to compile time and made that
structure const hoping that the compiler/linker/kernel will put the
structure into read-only memory so if anything tries to write to it,
I'd get the crash at that time. Guess what happened: the original
crash went away. Probably the memory was reorganized in a way that the
stray overwrite now didn't touch this particular variable. And no,
memory debuggers didn't help, ElectricFence didn't found the error,
Valgrind didn't worked in that environment. I'm so glad that I don't
have to work on that kind of C code anymore.



More information about the erlang-questions mailing list