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

Avoid hang when linting projects with symlink loops #175

Merged
merged 3 commits into from
May 26, 2021
Merged

Avoid hang when linting projects with symlink loops #175

merged 3 commits into from
May 26, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented May 26, 2021

Specific combinations of symlinks can cause infinite recursion loops during project discovery. This can be avoided by
limiting the depth of symlink follows to a reasonable number.

This was implemented in ef717d2 to make the project discovery code gracefully avoid perpetual recursion in this situation. Unfortunately, it turned out that the project data collection phase that comes after project discovery also suffers from the same problem. Fixing that is more difficult since the incompatible code is in Arduino CLI. So for now the provisional fix is to panic during the project discovery phase, which will at least avoid the far worse behavior of a permanent hang.

@per1234 per1234 added type: bug topic: code Related to content of the project itself labels May 26, 2021
@per1234 per1234 changed the title Avoid hang during discovery in projects with symlink loops Avoid hang when linting projects with symlink loops May 26, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2021

Codecov Report

Merging #175 (17c7b7c) into main (85638b8) will decrease coverage by 0.02%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #175      +/-   ##
==========================================
- Coverage   84.34%   84.32%   -0.03%     
==========================================
  Files          43       43              
  Lines        2971     2979       +8     
==========================================
+ Hits         2506     2512       +6     
- Misses        373      374       +1     
- Partials       92       93       +1     
Flag Coverage Δ
unit 84.32% <81.81%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
internal/project/project.go 92.90% <81.81%> (-0.98%) ⬇️

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 85638b8...17c7b7c. Read the comment docs.

internal/project/project.go Outdated Show resolved Hide resolved
Specific combinations of symlinks can cause infinite recursion loops during project discovery. This is avoided by
limiting the depth of symlink follows to a reasonable number.
Even though the previous commit caused the project discovery code to gracefully avoid perpetual recursion when specific
configurations of symlinks are present in the linting target path, it turned out that the project data phase that comes
after is also not able to handle this correctly, and fixing that is more difficult since the incompatible code is in
Arduino CLI. So for now the provisional fix is to panic during the project discovery phase, which will at least avoid the
far worse behavior of a permanent hang.
@per1234 per1234 merged commit 98ab6a2 into arduino:main May 26, 2021
@per1234 per1234 deleted the handle-symlink-loop branch May 26, 2021 16:39
@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
@per1234 per1234 self-assigned this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants