-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Improve CHECK-failure when passing a negative id to a ValueStore #6370 #6392
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
Improve CHECK-failure when passing a negative id to a ValueStore #6370 #6392
Conversation
…on-language#6370 Otherwise the value fails in confusing ways while untagging: CHECK failure at ./toolchain/base/value_store.h:71: index >= initial_reserved_ids_: When removing tagging bits, found an index that shouldn't've been tagged in the first place. With this change: CHECK failure at ./toolchain/base/fixed_size_value_store.h:112: id.index >= 0: instFFFFFFFFFFFFFFFD
Do you think we can print negative values as negative instead of as a large positive number? |
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.
Looking at #6310, I think we need to do the same in relational_value_store.h too, as GetRawIndex starts with Remove()?
I think we need to do something for a bunch of id types, I have a PR for this in the works. |
| // Given the related ID and a value, stores the value and returns a mapped ID | ||
| // to reference it in the store. | ||
| auto Add(RelatedIdType related_id, ValueType value) -> IdT { | ||
| auto related_index = related_store_->GetRawIndex(related_id); |
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.
This GetRawIndex calls Remove() which makes the confusing error in the negative case right? Do we want the DCHECK in here and TryGetId?
Made the same transformation for |
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.
Oh I see, this LGTM
Re performance, the checks are debug only and cheap so I don't think it's really a concern but this is okay as is.
Otherwise the value fails in confusing ways while untagging:
CHECK failure at ./toolchain/base/value_store.h:71:
index >= initial_reserved_ids_: When removing tagging bits,
found an index that shouldn't've been tagged in the first place.
With this change:
CHECK failure at ./toolchain/base/fixed_size_value_store.h:112:
id.index >= 0: instFFFFFFFFFFFFFFFD