Erlang on FreeBSD/amd64

Brian Buchanan <>
Thu Feb 10 07:03:27 CET 2005


Benno,

I just did a little investigative work on this.  Here's an error I get:

=ERROR REPORT==== 9-Feb-2005::21:47:41 ===
Error in process <0.22.0> with exit value:
{badarg,[{erlang,demonitor,[{}]},{io,wait_io_mon_reply,2},{epp,scan_toks,2}]}

./disk_log.erl:none: internal error in parse_module;
crash reason: {badarg,[{erlang,demonitor,[{}]},
                       {io,wait_io_mon_reply,2},
                       {epp,scan_toks,2}]}


I instrumented the bootstrap version of the io module and discovered what
appears to be reference corruption in the interpreter after a process
waits in "receive".

My modified "io" prints out {monitor, MRef} after the call to
erlang:monitor in io:receive, {wait_io_mon_reply,MRef} at the top of
wait_io_mon_reply(), and {demonitor, MRef} right before the call to
erlang:demonitor().

The output should look like a bunch of:

{monitor,#Ref<0.0.0.122>}
{wait_io_mon_reply,#Ref<0.0.0.122>}
{demonitor,#Ref<0.0.0.122>}
{monitor,#Ref<0.0.0.124>}
{wait_io_mon_reply,#Ref<0.0.0.124>}
{demonitor,#Ref<0.0.0.124>}

etc.

And that's what I get for the first many iterations.  Then:

{monitor,#Ref<0.0.0.178>}
{wait_io_mon_reply,#Ref<0.0.0.178>}
{demonitor,{}}

(crash!)

Here's the first fragment of io:wait_mon_reply/2 so you can see my
modifications.

wait_io_mon_reply(From, Mref) when is_reference(Mref) ->
    erlang:display({wait_io_mon_reply, Mref}),
    receive
        {io_reply,From,Reply} ->
            erlang:display({demonitor, Mref}),
            erlang:demonitor(Mref),
            receive
                {'DOWN', Mref, _, _, _} -> true
            after 0 -> true


I made a few more tweaks after this to try to figure out if the
interpreter stack was being clobbered, but determined that the "From"
variable and any new variables I defined before the receive were not
affected.  I suspect something is broken in the implementation of
references.

Unfortunately, I have no real experience with the beam interpreter, and at
this point am not even sure how to get it running in gdb, so I must appeal
to someone more knowledgeable to provide some guidance here.

- Brian

-- 
Brian Buchanan <>
Principal Engineer
nCircle Network Security                             http://www.ncircle.com/



More information about the erlang-bugs mailing list