[erlang-bugs] Bug: process unexpectedly exits loop

Sam Bobroff sam@REDACTED
Tue May 4 01:23:26 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Doug,

On 4/05/10 6:51 AM, Doug Edmunds (gmail) wrote:
> Hello,
> 
> I'm posting a module (conn3.erl) below.
> This module builds a hierarchical tree of PIDs.
> There are two loops, one for entries, and another
> for the position in the tree(called 'me').

[snip]

Getting a backtrace often helps. This is what I did:

$ erl
Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0]
[kernel-poll:false]

Eshell V5.7.4  (abort with ^G)
1> conn3_full:start().
- --setting me to top: self(): <0.34.0> M: <0.35.0> K: [] P: []
- --setting top self(): <0.35.0> M: <0.35.0> K: [] P []
ok
- --show self():<0.34.0> M: <0.35.0> K: [<0.37.0>,<0.36.0>] P: []
2> me ! down.
[{1,<0.37.0>},{2,<0.36.0>}]
down
3> {backtrace, BT} = process_info(whereis(me), backtrace).
{backtrace,<<"Program counter: 0x0079f3c8 (io:wait_io_mon_reply/2 +
28)\nCP: 0x00000000 (invalid)\narity = 0\n\n0x002f6cbc Ret"...>>}
4> io:fwrite("~s\n", [binary_to_list(BT)]).
Program counter: 0x0079f3c8 (io:wait_io_mon_reply/2 + 28)
CP: 0x00000000 (invalid)
arity = 0

0x002f6cbc Return addr 0x007a14c0 (conn3_full:get_user_input/1 + 20)
y(0)     #Ref<0.0.0.37>
y(1)     <0.25.0>

0x002f6cc8 Return addr 0x007a0bf4 (conn3_full:me_loop/3 + 676)

0x002f6ccc Return addr 0x001a1df4 (<terminate process normally>)
y(0)     []
y(1)     [{1,<0.37.0>},{2,<0.36.0>}]
y(2)     []
y(3)     [<0.37.0>,<0.36.0>]
y(4)     <0.35.0>

ok

I can see that "me" is still in it's loop and that it's currently in
"io:wait_io_mon_reply". I don't know exactly what this function is but
my guess would be it's something to do with the shell and io:get_line
(actually wait_io_mon_reply) fighting over the terminal input. If we try
again with -noshell it might be better but then we won't be able to use
the shell to send messages to "me".

So, I modified the source to add "me ! down" in the set up sequence at
line 16, and also uncommented the debug at the top of me_loop, and now I
get:

$ erl -noshell -run conn3_full
- --me_loop self(): <0.29.0> M: [] K:[] P: []
- --setting top self(): <0.30.0> M: <0.30.0> K: [] P []
- --setting me to top: self(): <0.29.0> M: <0.30.0> K: [] P: []
- --me_loop self(): <0.29.0> M: <0.30.0> K:[] P: []
- --me_loop self(): <0.29.0> M: <0.30.0> K:[<0.31.0>] P: []
- --me_loop self(): <0.29.0> M: <0.30.0> K:[<0.32.0>,<0.31.0>] P: []
- --show self():<0.29.0> M: <0.30.0> K: [<0.32.0>,<0.31.0>] P: []
- --me_loop self(): <0.29.0> M: <0.30.0> K:[<0.32.0>,<0.31.0>] P: []
[{1,<0.32.0>},{2,<0.31.0>}]
Enter key: 2
- --me_loop self(): <0.29.0> M: <0.30.0> K:[<0.32.0>,<0.31.0>] P: []
- --me_loop self(): <0.29.0> M: <0.31.0> K:[] P: <0.30.0>

I entered "2" at the prompt and the loop has continued :-)

Does that help?

Sam.
- -- 
Sam Bobroff | sam@REDACTED | M5 Networks
Why does my email have those funny headers? Because I use PGP to sign
my email (and you should too!): that's how you know it's really from me.
See: http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvfWu4ACgkQm97/UHSa/ASGbgCfaTDDP+03OxOKCaPzcYT46KGU
0b4An0mNhTQl6prV6AIML03ptKzMBACT
=m0bU
-----END PGP SIGNATURE-----


More information about the erlang-bugs mailing list