gen_server error report issue

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

gen_server error report issue

Aleksander Nycz-2

I think I've found some problem in gen_server error report:

when terminate callback throw errors then earlier errors (eg. from handle_call callback) is not reported.

Please compile and run provided simple_server.erl module, that implement gen_server behaviour:

([hidden email])4> simple_server:start_link(false).
([hidden email])5> simple_server:perform(false).
([hidden email])6> simple_server:perform(true).
** exception exit: perform_error_in_handle_call
     in function  simple_server:handle_call/3 (loadController/src/simple_server.erl, line 89)
     in call from gen_server:try_handle_call/4 (gen_server.erl, line 629)
     in call from gen_server:handle_msg/5 (gen_server.erl, line 661)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 240)
([hidden email])7>
=ERROR REPORT==== 16-Mar-2016::15:36:35 ===
** Generic server simple_server terminating
** Last message in was {perform,true}
** When Server state == {state,false}
** Reason for termination ==
** {perform_error_in_handle_call,

In this case we can see that exception was thrown 'in function  simple_server:handle_call/3 (loadController/src/simple_server.erl, line 89)'

And now please start server in this way:

([hidden email])7> simple_server:start_link(true).
([hidden email])8> simple_server:perform(false).
([hidden email])9> simple_server:perform(true).

=ERROR REPORT==== 16-Mar-2016::15:37:30 ===
** Generic server simple_server terminating
** Last message in was {perform,true}
** When Server state == {state,true}
** Reason for termination ==
** {throw_error_in_terminate_callback,
** exception exit: throw_error_in_terminate_callback
     in function  simple_server:terminate/2 (loadController/src/simple_server.erl, line 141)
     in call from gen_server:try_terminate/3 (gen_server.erl, line 643)
     in call from gen_server:terminate/7 (gen_server.erl, line 809)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 240)

Now gen_server is also terminating, but we can only see exception from terminate callback.

Exception that causes gen_server termination is not reported.
I rather expect that both exceptions will be shown.

Aleksander Nycz

Aleksander Nycz
Chief Designer
Telco_021 BSS R&D
Comarch SA
Phone:  +48 17 785 5909
Mobile: +48 691 464 275
website: www.comarch.pl

erlang-bugs mailing list
[hidden email]

simple_server.erl (7K) Download Attachment
smime.p7s (6K) Download Attachment