[erlang-bugs] release_handler:find_script() behind the times

Ulf Wiger ulf@REDACTED
Tue May 1 12:49:47 CEST 2012


I'm playing around with release_handler, since it's a holiday, and I need something fun to do…

Erlang R15B (erts-5.9) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9  (abort with ^G)
1> Appup = filename:join([code:lib_dir(stdlib), "ebin", "stdlib.appup"]).
"/usr/lib/erlang/lib/stdlib-1.18/ebin/stdlib.appup"
2> rp(file:consult(Appup)).
{ok,[{"1.18",
      [{<<"1\\.18(\\.[0-9]+)*">>,[restart_new_emulator]},
       {<<"1\\.17(\\.[0-9]+)*">>,[restart_new_emulator]},
       {<<"1\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}],
      [{<<"1\\.18(\\.[0-9]+)*">>,[restart_new_emulator]},
       {<<"1\\.17(\\.[0-9]+)*">>,[restart_new_emulator]},
       {<<"1\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}]}]}
ok
3> release_handler:upgrade_script(stdlib,code:lib_dir(stdlib)).
** exception throw: {version_not_in_appup,"1.18"}
     in function  release_handler:find_script/4 (release_handler.erl, line 501)
     in call from release_handler:upgrade_script/2 (release_handler.erl, line 439)


Ok, an odd practice to try to upgrade an app to itself, but it was just a test.

The thing to note is that release_handler:upgrade_script/2 ends up calling release_handler:find_script/4, which looks like this:

find_script(App, Dir, OldVsn, UpOrDown) ->
    Appup = filename:join([Dir, "ebin", atom_to_list(App)++".appup"]),
    case file:consult(Appup) of
        {ok, [{NewVsn, UpFromScripts, DownToScripts}]} ->
            Scripts = case UpOrDown of
                          up -> UpFromScripts;
                          down -> DownToScripts
                      end,
            case lists:keysearch(OldVsn, 1, Scripts) of
                {value, {_OldVsn, Script}} ->
                    {NewVsn, Script};
                false ->
                    throw({version_not_in_appup, OldVsn})
            end;
        {error, enoent} ->
            throw(no_appup_found);
        {error, Reason} ->
            throw(Reason)
    end.

It tries to find the OldVsn using lists:keysearch/3, which can't possibly work, given the kind of .appup found in a modern OTP.

Apologies for not just fixing it and submitting a patch, but there has to be a limit even to holiday fun.

BR,
Ulf W

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com






More information about the erlang-bugs mailing list