Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix issue with temporary children introduced by OTP-9064
The temporary child specs are never removed from the supervisor's state, and
have they're MFA component set to {M, F, undefined} instead of the MFA passed
in the supervisor:start_child/2 call. Subsequent calls to supervisor:restart_child/2
may crash. Stack trace example:

{badarg,[{erlang,apply,[gen_server,start_link,undefined]},
{supervisor,do_start_child,2},{supervisor,handle_call,3},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
  • Loading branch information
fdmanana authored and IngelaAndin committed Apr 4, 2011
1 parent 8773ee1 commit 19ca18f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/stdlib/src/supervisor.erl
Expand Up @@ -817,8 +817,12 @@ state_del_child(Child, State) ->
NChildren = del_child(Child#child.name, State#state.children),
State#state{children = NChildren}.

del_child(Name, [Ch|Chs]) when Ch#child.name =:= Name, Ch#child.restart_type =:= temporary ->
[Chs];
del_child(Name, [Ch|Chs]) when Ch#child.name =:= Name ->
[Ch#child{pid = undefined} | Chs];
del_child(Pid, [Ch|Chs]) when Ch#child.pid =:= Pid, Ch#child.restart_type =:= temporary ->
[Chs];
del_child(Pid, [Ch|Chs]) when Ch#child.pid =:= Pid ->
[Ch#child{pid = undefined} | Chs];
del_child(Name, [Ch|Chs]) ->
Expand Down

0 comments on commit 19ca18f

Please sign in to comment.