Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent infinite DAG growth #2892

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/rebar/src/rebar_compiler_dag.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,21 @@ finalise_populate_sources_(G, InDirs, [{Status, {deps, Source, AbsIncls}}|Acc])
{_, _Src, Path, _Label} <- [digraph:edge(G, Edge)],
not lists:member(Path, AbsIncls)],
%% Add the rest
[digraph:add_edge(G, Source, Incl) || Incl <- AbsIncls],
RemainingEdges = [digraph:edge(G, E) || E <- digraph:out_edges(G, Source),
AbsIncls =/= []],
[digraph:add_edge(G, Source, Incl) || Incl <- AbsIncls,
not in_edges(Source, Incl, RemainingEdges)],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So add it if its not already in the edges?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. Problem was that edges can be duplicated and I assumed they weren't.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, surprised me too seeing this patch.

%% mark the digraph dirty when there is any change in
%% dependencies, for any application in the project
mark_dirty(G),
finalise_populate_sources_(G, InDirs, Acc).

%% @private look if two vertices `V1' and `V2' exist in an unsorted set
%% of DAG edges (in expanded format).
in_edges(_, _, []) -> false;
in_edges(V1, V2, [{_, V1, V2, []}|_]) -> true;
in_edges(V1, V2, [_|T]) -> in_edges(V1, V2, T).

%% @doc this function scans all the source files found and looks into
%% all the `InDirs' for deps (other source files, or files that aren't source
%% but still returned by the compiler module) that are related
Expand Down
Loading