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

Guard against self-referential aliases #305

Merged
merged 1 commit into from
Oct 16, 2019

Conversation

phi-gamma
Copy link
Contributor

When resolving task aliases, error out if the alias matches the
name of the current task to prevent infinite recursion:

Example Makefile.toml:

## error:
##    thread 'main' has overflowed its stack
##    fatal runtime error: stack overflow
##    Aborted (core dumped)
[tasks.rec]
alias = "rec"

@sagiegurari
Copy link
Owner

unfortunately, there are endless ways to get into infinite loop.
wish we could do a more bulletproof solution but I'll accept this one as well.
thanks a lot for the PR. I'll merge it once the CI finishes

When resolving task aliases, keep track of aliases that were
already considered and error out when an already resolved alias
is hit again.

Example Makefile.toml:

    ## error:
    ##    thread 'main' has overflowed its stack
    ##    fatal runtime error: stack overflow
    ##    Aborted (core dumped)
    [tasks.rec]
    alias = "rec"

    [tasks.rec-mut-a]
    alias = "rec-mut-b"

    [tasks.rec-mut-b]
    alias = "rec-mut-a"

To aid debugging the error message shows the complete cycle:

    Detected cycle while resolving alias rec-mut-b: rec-mut-a -> rec-mut-b
@codecov-io
Copy link

codecov-io commented Oct 16, 2019

Codecov Report

Merging #305 into master will decrease coverage by <.01%.
The diff coverage is 91.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #305      +/-   ##
==========================================
- Coverage   93.38%   93.38%   -0.01%     
==========================================
  Files          86       86              
  Lines       14910    14945      +35     
==========================================
+ Hits        13924    13956      +32     
- Misses        986      989       +3
Impacted Files Coverage Δ
src/lib/execution_plan.rs 92.7% <91.66%> (-0.15%) ⬇️
src/lib/execution_plan_test.rs 95.18% <92%> (-0.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5130cf8...e706ae5. Read the comment docs.

@phi-gamma
Copy link
Contributor Author

unfortunately, there are endless ways to get into infinite loop.

I just realized that as well, see the updated commit.

@sagiegurari sagiegurari merged commit 528f920 into sagiegurari:master Oct 16, 2019
@sagiegurari
Copy link
Owner

great stuff!!! thanks a lot.

@sagiegurari sagiegurari modified the milestones: 0.23.1, 0.24.0 Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants