-
Notifications
You must be signed in to change notification settings - Fork 660
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
Slip lane detection: track visited nodes to avoid infinite loops #3297
Conversation
if (node_edge.second != prev_edge_idx && !edge.attributes.link && | ||
IsEdgeDriveableInDirection(node, edge, forward)) { | ||
if (!edge.attributes.link && IsEdgeDriveableInDirection(node, edge, forward) && | ||
visited_nodes.find(EndNode(node, node_edge.first)) == visited_nodes.end()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the order of check to put hash set lookup in the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a test with 0-length edges in a gurka map?
@mandeepsandhu reasonable question. I thought about it. My view is it should be possible in theory but it can take much efforts as this bug depends on the order of edges in the data so the test can become useless after code tweaks in the future. |
Yeah, you dont have to spend too much time trying to recreate it in gurka (especially if the tests is going to be fragile). BTW, is it possible to test with a OSM extract of the area where @gknisely made the edit? I dont know if cutting a small pbf around that area can help recreate the issue. |
@mandeepsandhu I believe valhalla policy is not to use osm extracts and replace them with gurka tests
That's exactly how I tested the PR but locally |
True, in that we prefer to add gurka tests for most of our tests. Although I believe exceptions can be made if its difficult or hard-to-reproduce the bug in gurka. This code might change in the future so it'll be good to have some form of test to catch possible regressions. |
@mandeepsandhu There's some dark magic happened with this extract. @gknisely and I, we tried to reproduce it with a gurka test but without success. Going to merge it as it is. Local testing should be enough to be safe to merge it(though would be better with gurka 😢 ) note: here's an extract how to assign the same coordinates for two nodes, maybe it'll be helpful in the future itr = layout.find("D");
EXPECT_NE(itr, layout.end());
midgard::PointLL ll = itr->second;
itr = layout.find("C");
EXPECT_NE(itr, layout.end());
itr->second = ll; |
Issue
There was an edge with 2 extremely close nodes in the data and distance threshold was never exhausted because edge length was zero. Finally it caused infinite loop and OOM https://github.com/valhalla/valhalla/blob/master/src/mjolnir/linkclassification.cc#L561
The issue is gone now after @gknisely's OSM fix . But it makes sense prevent such looping in the code
This PR adds more robust way not to loop(track all nodes instead of tracking previous edge)
Tests:
maryland.osm.pbf
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?