alertlogic/erllambda

Bad call to erllamba:message/2 breaks subsequent logging

rmpalomino opened this issue · 0 comments

Similar to #45.

Calling erllambda:message/2 breaks logging by causing a crash in io_lib:scan_format/2, in turn causing the error_logger handler to be unregistered permanently.

If I'm reading the OTP gen_event documentation right and testing right, the erllamba_error_handler gen_event behavior doesn't actually crash and get re-initialized. It just gets its terminate/2 method called and unregistered from error_logger. Since the behavior is added as a handler during its initialization, but never re-initialized, it is never re-added as a handler.

Edit: Short reproduction steps in rebar3 shell:

1> erllambda:message("Good ~s", [<<"format">>]).
ok
Good format
2> erllambda:message("Bad format", [any]).
ok
3> erllambda_error_handler terminated with reason {error,{'EXIT',{badarg,[{io_lib,scan_format,[[66,97,100,32,102,111,114,109,97,116],[any]],[{file,[105,111,95,108,105,98,46,101,114,108]},{line,215}]},{erllambda,line_format,2,[{file,[47,85,115,101,114,115,47,114,112,97,108,111,109,105,110,111,47,116,101,109,112,47,101,114,108,108,97,109,98,100,97,47,95,98,117,105,108,100,47,100,101,102,97,117,108,116,47,108,105,98,47,101,114,108,108,97,109,98,100,97,47,115,114,99,47,101,114,108,108,97,109,98,100,97,46,101,114,108]},{line,330}]},{erllambda_error_handler,output,2,[{file,[47,85,115,101,114,115,47,114,112,97,108,111,109,105,110,111,47,116,101,109,112,47,101,114,108,108,97,109,98,100,97,47,95,98,117,105,108,100,47,100,101,102,97,117,108,116,47,108,105,98,47,101,114,108,108,97,109,98,100,97,47,115,114,99,47,101,114,108,108,97,109,98,100,97,95,101,114,114,111,114,95,104,97,110,100,108,101,114,46,101,114,108]},{line,88}]},{erllambda_error_handler,handle_event,2,[{file,[47,85,115,101,114,115,47,114,112,97,108,111,109,105,110,111,47,116,101,109,112,47,101,114,108,108,97,109,98,100,97,47,95,98,117,105,108,100,47,100,101,102,97,117,108,116,47,108,105,98,47,101,114,108,108,97,109,98,100,97,47,115,114,99,47,101,114,108,108,97,109,98,100,97,95,101,114,114,111,114,95,104,97,110,100,108,101,114,46,101,114,108]},{line,57}]},{gen_event,server_update,4,[{file,[103,101,110,95,101,118,101,110,116,46,101,114,108]},{line,577}]},{gen_event,server_notify,4,[{file,[103,101,110,95,101,118,101,110,116,46,101,114,108]},{line,559}]},{gen_event,handle_msg,6,[{file,[103,101,110,95,101,118,101,110,116,46,101,114,108]},{line,300}]},{proc_lib,init_p_do_apply,3,[{file,[112,114,111,99,95,108,105,98,46,101,114,108]},{line,249}]}]}}} and state #{}
3> erllambda:message("Good ~s", [<<"format">>]).
ok