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

Fix ubsan error due to possible invalid shift exponent #3450

Merged
merged 2 commits into from Dec 8, 2021

Conversation

mandeepsandhu
Copy link
Contributor

ubsan complained about the shift exponent in NodeInfo::heading() being
possibly too large under some conditions.

Fixed by checking for valid localidx. If invalid index is passed in, we
log a warning and return a heading of 0.

ubsan complained about the shift exponent in NodeInfo::heading() being
possibly too large under some conditions.

Fixed by checking for valid localidx. If invalid index is passed in, we
log a warning and return a heading of 0.
@kevinkreiser
Copy link
Member

kevinkreiser commented Dec 8, 2021

i saw this too but what i wonder is why is the local index out of range in the first place? specifically what changed? i know you can have tons of edges connecting at a node and go past the maximum that we support so the check you added is fine but what changed that exposed this particular situation?

@mandeepsandhu
Copy link
Contributor Author

what changed that exposed this particular situation?

I haven't run bisect, so can't say which change introduced this bug. Was ubsan always on? or was it switched on recently?

@mandeepsandhu
Copy link
Contributor Author

i saw this too but what i wonder is why is the local index out of range in the first place?

I see some places where we're looping the edge count and passing that as index into NodeInfo::heading (without capping it at 7)), so seems quite likely that this index goes out of valid range. eg: IsInternalIntersection passes the idx arg as-is into NodeInfo::heading (idx if fetch from a loop through the node's edges). There might be more instances of such usage.

@dnesbitt61
Copy link
Member

This might only be used in map-matching. I am thinking we should use turn types there and then we wouldn't even need this

@kevinkreiser
Copy link
Member

yep @mandeepsandhu i totally get why it happens i just dont get why it started happening in the check target semi-recently. something changing elsewhere must have caused it and thats what im interested in.

and yeah @dnesbitt61 has made this point before i think, perhaps we can just jetison it completely?

@dgearhart
Copy link
Member

This might only be used in map-matching. I am thinking we should use turn types there and then we wouldn't even need this

@dnesbitt61 @kevinkreiser we use the intersecting edge begin heading - can not remove it

Copy link
Member

@dgearhart dgearhart left a comment

Choose a reason for hiding this comment

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

🚢 we will keep our eyes out for reason of recent failure

@mandeepsandhu mandeepsandhu merged commit f622de1 into master Dec 8, 2021
@mandeepsandhu
Copy link
Contributor Author

yep @mandeepsandhu i totally get why it happens i just dont get why it started happening in the check target semi-recently. something changing elsewhere must have caused it and thats what im interested in.

As I said, a time-consuming git-bisect can telll us exactly when it started occurring. Initially I though usan must've been enabled recently, but I think its been on for some time now (unless some ubsan configuration changed recently).

and yeah @dnesbitt61 has made this point before i think, perhaps we can just jetison it completely?

@dnesbitt61
Copy link
Member

dnesbitt61 commented Dec 8, 2021

Unfortunately we need it (even if we change map matching) to get the heading of intersecting edges along the path. If we remove it we would have to access other tiles (level 2 in particular) along the route which would slow things down considerably.This would undo much of the benefits of hierarchies.

@nilsnolde nilsnolde deleted the ubsan_fix_shift_exponent_too_large branch February 24, 2024 15:04
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

4 participants