supervisor doesn't like abstract modules

Mark Scandariato mscandar@REDACTED
Fri Apr 8 16:11:01 CEST 2005


Starting a child using a module instance as the module fails:

** exited: {{nocatch,{error,{invalid_mfa,
                                 {{foo,bar,baz},
                                  start_link,
                                  [one,two,three]}}}}

Turns out there are some checks in supervisor.erl that expect a module to be an atom:

validFunc({M, F, A}) when atom(M), atom(F), list(A) -> true;
validFunc(Func)                                 -> throw({invalid_mfa, Func}).


and

validMods(dynamic) -> true;
validMods(Mods) when list(Mods) ->
     lists:foreach(fun(Mod) ->
             if
             atom(Mod) -> ok;
             true -> throw({invalid_module, Mod})
             end
           end,
           Mods);
validMods(Mods) -> throw({invalid_modules, Mods}).


I changed them to the following and all is well (so far):

validMods(dynamic) -> true;
validMods(Mods) when list(Mods) -> true;
validMods(Mods) -> throw({invalid_modules, Mods}).

validFunc({M, F, A}) when atom(F), list(A) -> true;
validFunc(Func)                                 -> throw({invalid_mfa, Func}).


Mark.



More information about the erlang-bugs mailing list