Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  erlang:monitor can hang under certain conditions

mickael.remond at erlang-
Posted: Mon Nov 21, 2005 8:22 am Reply with quote
Guest
Hello,

The following problem has been brought to my attention:
If this happen to be really a bug, it could trigger deadlock when using
Erlang monitor for a disappered process.
The ProcessId is a local processid, but the node has changed in the
meantime. It seems to confuse the monitor.

Here is how to reproduce it.
************ ping.erl *******************
-module(ping).
-export([start/0,loop/1]).


start() ->
register(ping,spawn(ping,loop,[initial])).

loop(X) ->
receive
{store, Y} -> loop(Y);
{retrieve, Pid} when pid(Pid) -> Pid ! X, loop(X)
end.
****************************************

First time, the Erlang monitor is not hanging:
$ erl -sname ping -s ping -detached
$ erl -sname hanger
Erlang (BEAM) emulator version 5.4.4 [source] [threads:0]

Eshell V5.4.4 (abort with ^G)
(hanger_at_louxor-erlang-fr-org)1> OldPid = spawn(io, format, ["ok",""]).
ok<0.37.0>
...
(hanger_at_louxor-erlang-fr-org)4> {ping, 'ping_at_louxor-erlang-fr-org'} !
{store, OldPid}.
{store,<0.37.0>}
(hanger_at_louxor-erlang-fr-org)5> {ping, 'ping_at_louxor-erlang-fr-org'} !
{retrieve, self()}.
{retrieve,<0.42.0>}
(hanger_at_louxor-erlang-fr-org)6> RetPid = receive X -> X end.
<0.37.0>
(hanger_at_louxor-erlang-fr-org)7> erlang:monitor(process,RetPid).
#Ref<0.0.0.68>
(hanger_at_louxor-erlang-fr-org)8> halt().


Second time:
erl -sname hanger
Erlang (BEAM) emulator version 5.4.4 [source] [threads:0]
Eshell V5.4.4 (abort with ^G)
(hanger_at_louxor-erlang-fr-org)1> {ping, 'ping_at_louxor-erlang-fr-org'} !
{retrieve, self()}.
{retrieve,<0.35.0>}
(hanger_at_louxor-erlang-fr-org)2> RetPid = receive X -> X end.
<0.37.0>
(hanger_at_louxor-erlang-fr-org)3> RetPid.
<0.37.0>
(hanger_at_louxor-erlang-fr-org)4> erlang:monitor(process,RetPid).

The function never returns.

I have started looking at the Erlang code to analyze more deeply the
problem, but I thought that it might be interesting to share the
information.

Cheers,

--
Micka
mickael.remond at process
Posted: Mon Nov 21, 2005 8:22 am Reply with quote
Guest
Hello,

The following problem has been brought to my attention:
If this happen to be really a bug, it could trigger deadlock when using
Erlang monitor for a disappered process.
The ProcessId is a local processid, but the node has changed in the
meantime. It seems to confuse the monitor.

Here is how to reproduce it.
************ ping.erl *******************
-module(ping).
-export([start/0,loop/1]).


start() ->
register(ping,spawn(ping,loop,[initial])).

loop(X) ->
receive
{store, Y} -> loop(Y);
{retrieve, Pid} when pid(Pid) -> Pid ! X, loop(X)
end.
****************************************

First time, the Erlang monitor is not hanging:
$ erl -sname ping -s ping -detached
$ erl -sname hanger
Erlang (BEAM) emulator version 5.4.4 [source] [threads:0]

Eshell V5.4.4 (abort with ^G)
(hanger_at_louxor-erlang-fr-org)1> OldPid = spawn(io, format, ["ok",""]).
ok<0.37.0>
...
(hanger_at_louxor-erlang-fr-org)4> {ping, 'ping_at_louxor-erlang-fr-org'} !
{store, OldPid}.
{store,<0.37.0>}
(hanger_at_louxor-erlang-fr-org)5> {ping, 'ping_at_louxor-erlang-fr-org'} !
{retrieve, self()}.
{retrieve,<0.42.0>}
(hanger_at_louxor-erlang-fr-org)6> RetPid = receive X -> X end.
<0.37.0>
(hanger_at_louxor-erlang-fr-org)7> erlang:monitor(process,RetPid).
#Ref<0.0.0.68>
(hanger_at_louxor-erlang-fr-org)8> halt().


Second time:
erl -sname hanger
Erlang (BEAM) emulator version 5.4.4 [source] [threads:0]
Eshell V5.4.4 (abort with ^G)
(hanger_at_louxor-erlang-fr-org)1> {ping, 'ping_at_louxor-erlang-fr-org'} !
{retrieve, self()}.
{retrieve,<0.35.0>}
(hanger_at_louxor-erlang-fr-org)2> RetPid = receive X -> X end.
<0.37.0>
(hanger_at_louxor-erlang-fr-org)3> RetPid.
<0.37.0>
(hanger_at_louxor-erlang-fr-org)4> erlang:monitor(process,RetPid).

The function never returns.

I have started looking at the Erlang code to analyze more deeply the
problem, but I thought that it might be interesting to share the
information.

Cheers,

--
Micka
rickard.s.green at ericss
Posted: Mon Nov 21, 2005 8:59 am Reply with quote
Guest
Thanks, we will fix this in R10B-9.

Best Regards,
Rickard Green, Erlang/OTP

Mickael Remond wrote:
> Hello,
>
> The following problem has been brought to my attention:
> If this happen to be really a bug, it could trigger deadlock when using
> Erlang monitor for a disappered process.
> The ProcessId is a local processid, but the node has changed in the
> meantime. It seems to confuse the monitor.
>
> Here is how to reproduce it.
> ************ ping.erl *******************
> -module(ping).
> -export([start/0,loop/1]).
>
>
> start() ->
> register(ping,spawn(ping,loop,[initial])).
>
> loop(X) ->
> receive
> {store, Y} -> loop(Y);
> {retrieve, Pid} when pid(Pid) -> Pid ! X, loop(X)
> end.
> ****************************************
>
> First time, the Erlang monitor is not hanging:
> $ erl -sname ping -s ping -detached
> $ erl -sname hanger
> Erlang (BEAM) emulator version 5.4.4 [source] [threads:0]
>
> Eshell V5.4.4 (abort with ^G)
> (hanger_at_louxor-erlang-fr-org)1> OldPid = spawn(io, format, ["ok",""]).
> ok<0.37.0>
> ...
> (hanger_at_louxor-erlang-fr-org)4> {ping, 'ping_at_louxor-erlang-fr-org'} !
> {store, OldPid}.
> {store,<0.37.0>}
> (hanger_at_louxor-erlang-fr-org)5> {ping, 'ping_at_louxor-erlang-fr-org'} !
> {retrieve, self()}.
> {retrieve,<0.42.0>}
> (hanger_at_louxor-erlang-fr-org)6> RetPid = receive X -> X end.
> <0.37.0>
> (hanger_at_louxor-erlang-fr-org)7> erlang:monitor(process,RetPid).
> #Ref<0.0.0.68>
> (hanger_at_louxor-erlang-fr-org)8> halt().
>
>
> Second time:
> erl -sname hanger
> Erlang (BEAM) emulator version 5.4.4 [source] [threads:0]
> Eshell V5.4.4 (abort with ^G)
> (hanger_at_louxor-erlang-fr-org)1> {ping, 'ping_at_louxor-erlang-fr-org'} !
> {retrieve, self()}.
> {retrieve,<0.35.0>}
> (hanger_at_louxor-erlang-fr-org)2> RetPid = receive X -> X end.
> <0.37.0>
> (hanger_at_louxor-erlang-fr-org)3> RetPid.
> <0.37.0>
> (hanger_at_louxor-erlang-fr-org)4> erlang:monitor(process,RetPid).
>
> The function never returns.
>
> I have started looking at the Erlang code to analyze more deeply the
> problem, but I thought that it might be interesting to share the
> information.
>
> Cheers,
>


Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum