[erlang-questions] Pass message from C code to Erlang
Jachym Holecek
freza@REDACTED
Sat Aug 20 21:47:01 CEST 2011
# Alexander Kuleshov 2011-08-20:
> [... Code sample ommited ...]
>
> And i get error:
Presumably this is your program crashing, not the Erlang node?
> [Thread debugging using libthread_db enabled]
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x08055fac in ei_mutex_lock ()
>
> [... This is where backtrace wasn't included so we can't really know ...]
Let me guess: your C node isn't properly initialized (you don't call
erl_connect_init()) so ei_sockets_lock is NULL and the library explodes
as soon as you try to send a message (this tries to take the sockets
lock). Even if this wasn't the case, your sockfd is uninitialized so
things wouldn't work anyway :-).
And judging from the EI files involved being placed under src/legacy/
directory, you may be using some old API. Not sure, I've only ever used
the lowlevel encoding/decoding functions and ignored the C node parts
altogether.
Anyway, src/prog/erl_call.c in EI directory should be an illustrative
example of how to write a C node.
HTH,
-- Jachym
More information about the erlang-questions
mailing list