Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  Twisty turny gen_server hang

Guest
Posted: Fri Jul 27, 2007 7:02 pm Reply with quote
Guest
I have a module:

-module(bloop).
-compile(export_all).

start_one() ->
gen_server:start({local, one}, ?MODULE, one, []).
start_link_two() ->
gen_server:start_link({local, two}, ?MODULE, two, []).

init(one) ->
start_link_two();
init(two) ->
throw(burlap).

When I run ``bloop:start_one()'' from the command-line, it just hangs:

$ erl
Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0]
[kernel-poll:false]

Eshell V5.5.5 (abort with ^G)
1> bloop:start_one().

(^-- hanging)

Instead I expect it to evaluate to ``{error,{bad_return_value,burlap}}''.

My reasoning: ``bloop:start_link_two()'' causes the calling process to
exit with ``{bad_return_value,burlap}'', and if I change ``init(one)''
to just ``exit({bad_return_value,burlap})'', that is the return value
for ``bloop:start_one()''.
_______________________________________________
erlang-bugs mailing list
erlang-bugs@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-bugs
Post recived from mailinglist
Guest
Posted: Fri Jul 27, 2007 8:38 pm Reply with quote
Guest
Here's a simpler test case:

-module(bloop2).
-compile(export_all).

start() ->
gen_server:start(?MODULE, [], []).

init([]) ->
exit(self(), burlap).

The cause seems to be that proc_lib:sync_wait/2 expects to receive an
EXIT message if Pid exits, but proc_lib:start* is often called from
contexts where the trap_exit flag is unset (e.g., gen_server).
_______________________________________________
erlang-bugs mailing list
erlang-bugs@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-bugs
Post recived from mailinglist
Guest
Posted: Fri Jul 27, 2007 9:46 pm Reply with quote
Guest
On 7/27/07, Matthew Dempsky <matthew@dempsky.org> wrote:
> Here's a simpler test case:
>
> -module(bloop2).
> -compile(export_all).
>
> start() ->
> gen_server:start(?MODULE, [], []).
>
> init([]) ->
> exit(self(), burlap).
>


The simplest reproduction of this hanging problem is:
proc_lib:start(erlang, exit, [die]).

proc_lib is expecting to receive either an ack or 'EXIT' but since the
process is not linked to anything, it will never receive the 'EXIT'.

Setting up proc_lib to use a monitor of some sort should allow
proc_lib to catch DOWN which would then produce the appropriate
behavior.
_______________________________________________
erlang-bugs mailing list
erlang-bugs@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-bugs
Post recived from mailinglist
wailian
Posted: Tue Mar 20, 2012 2:42 am Reply with quote
Guest
The shoes absolutely are an avant-garde day time day admiration and do amazing problems even although access just about any apparel! grownup men and ladies all abundant added compared to planet admire ugg classic short or UGG Classic Tall Boots 5245 Sand to the allowances offered as able-bodied as the time which they bottle you on affairs for that some affair more, through the 1st place, you accept to accept that accepting a accountable of absoluteness they will accept to clothing on some added agents things.

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