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

Bugfix: Prevent GetShortcut to run into an infinite loop. #4532

Merged
merged 5 commits into from
Jan 29, 2024

Conversation

lakovacs2
Copy link
Contributor

Issue

If there is a loop of the edges that are all on the same level, and all the connecting edges to the loop are on other levels, and there are no shortcuts in the loop, then the original GraphReader::GetShortcut runs into infinite loop.
E.g. if there is a roundabout on level 1 and all the connecting edges are on level 2.

Lajos Kovács lajos.kovacs@nng.com NNG LLC.

@kevinkreiser
Copy link
Member

any chance we can add a gurka test for this? you seem to have quite a well described case here. of course the test would run for ever but after your fix the test should just exit normally 😄 would you be up for trying to add a test to here: https://github.com/valhalla/valhalla/blob/master/test/gurka/test_shortcut.cc

)";
const gurka::ways ways = {
{"AB",
{{"highway", "primary"}}},
Copy link
Member

@nilsnolde nilsnolde Jan 29, 2024

Choose a reason for hiding this comment

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

The test is simple and effective, thanks. However, I don’t think this would fail without your PR. I think the edges need more common attributes for them to form a shortcut IIRC, e.g. the same name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried and it runs into infinite loop without my PR, because GetShortcut try to find a shortcut and run along the edges in the loop. It doesn't fail, but run for ever without my PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ok perfect, I was pretty sure I was pulling my hair out a few times when it didn't produce shortcuts for some reason when I didn't include any other properties like name or so. Thanks for the feedback, LGTM.

nilsnolde
nilsnolde previously approved these changes Jan 29, 2024
@kevinkreiser
Copy link
Member

@lakovacs2 if you can pull master into your branch we can merge

@nilsnolde nilsnolde merged commit 154c47f into valhalla:master Jan 29, 2024
7 checks passed
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