Skip to content

Commit

Permalink
Prevent crashes on recursive src_dir definitions in deps
Browse files Browse the repository at this point in the history
In some rare cases (see erlang#2581
for a sample interplay between plugins and recursive dep definitions
with apps) there can be some interplay where a dependency declares
recursive directories but the lookup for app files does not acknowledges
these and causes problems.

This patch simply ignores such cases by stripping options; this should
have no backward compatibility impact since the value was just ignored
before anyway, but will prevent crashes in hard-to-reproduce cases.
  • Loading branch information
ferd committed Jun 18, 2021
1 parent a7ceae0 commit 30ca805
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/rebar_app_discover.erl
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,18 @@ find_app(AppInfo, AppDir, SrcDirs, Validate, State) ->
{true, rebar_app_info:t()} | false.
find_app_(AppInfo, AppDir, SrcDirs, Validate, State) ->
Extensions = rebar_state:get(State, application_resource_extensions, ?DEFAULT_APP_RESOURCE_EXT),
NormSrcDirs = [case SrcDir of
{SrcDir, _Opts} -> SrcDir;
_ -> SrcDir
end || SrcDir <- SrcDirs],
ResourceFiles = [
{app, filelib:wildcard(filename:join([AppDir, "ebin", "*.app"]))},
{mix_exs, filelib:wildcard(filename:join([AppDir, "src", "mix.exs"]))} |
[
{extension_type(Ext), lists:append([ filelib:wildcard(filename:join([AppDir, SrcDir, "*" ++ Ext]))
|| SrcDir <- SrcDirs])}
|| Ext <- Extensions
]],
{mix_exs, filelib:wildcard(filename:join([AppDir, "src", "mix.exs"]))}
| [{extension_type(Ext),
lists:append([filelib:wildcard(filename:join([AppDir, SrcDir, "*" ++ Ext]))
|| SrcDir <- NormSrcDirs])}
|| Ext <- Extensions]
],
FlattenedResourceFiles = flatten_resource_files(ResourceFiles),
try_handle_resource_files(AppInfo, AppDir, FlattenedResourceFiles, Validate).

Expand Down

0 comments on commit 30ca805

Please sign in to comment.