Erlang segfaults in erts_remove_monitor

Erik Søe Sørensen <>
Tue Dec 7 01:34:11 CET 2010

Hi there -
while working on the distribution subsystem of Erjang, I ran into this: 
beam core dumping, reproducibly.

(1) An Erjang node[1] is started as ; an Erlang node (R14B) is 
started as 
(2) ()1> net_adm:ping().
(3) ()1> global:register_name(foo, self()), throw(x).


Output from  c@ :

    Segmentation fault

Output from j@ (mostly distribution-related debugging messages):

    sending msg {} !
    sending msg {} !
    sending msg {} !
    ** exception throw: x
          in function  apply/3
    [snip stack trace]

Reproducing the problem with GDB attached reveals this:

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0xb6413b70 (LWP 4282)]
    erts_remove_monitor (root=0x94495b0, ref=587) at beam/erl_monitors.c:615
    615        } else if ((c = CMP_MON_REF(ref,(*this)->ref)) < 0) {

with the stack trace

    #0  erts_remove_monitor (root=0x94495b0, ref=587) at
    #1  0x081021d1 in erts_net_message (prt=0xb75adb60, dep=0x9449530,
         hlen=0, buf=0x946aabc "\203D", len=57) at beam/dist.c:1274
    #2  0x080d0b6e in driver_output2 (ix=609, hbuf=0x946aabc "\203D",
         buf=0x0, len=0) at beam/io.c:3277
    #3  0x081adede in inet_port_data (desc=0x94a9388, len=61)
         at drivers/common/inet_drv.c:1889
    #4  tcp_reply_data (desc=0x94a9388, len=61) at
    #5  tcp_deliver (desc=0x94a9388, len=61) at

I don't know what to look for here, but...:

    (gdb) print this
    $1 = (ErtsMonitor **) 0x94495b0
    (gdb) print *this
    $2 = (ErtsMonitor *) 0xb761f77c
    (gdb) print (*this)->ref
    $3 = 3076650902
    (gdb) print c
    $4 = <value optimised out>
    (gdb) print ref
    $5 = 587

As far as I can tell, ref is the odd value here (should be pointer-like, 

Hoping this will make sense to someone,
Erik Søe Sørensen

[1] Erjang version in question is this one:

More information about the erlang-bugs mailing list