-
Notifications
You must be signed in to change notification settings - Fork 51
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: correctly return tombstone when theres no free element #728
Conversation
The dict findDictEntry function did not correctly handle the case when, a dict had no "free" slot but had tombstones, it would loop forever. This fixes that by conditionally returning a tombstone when all other indexes where processed. Fixes: dictu-lang#726
We wouldn't want this as there is a potential that the element has wrapped around to the start - will need some more investigation into your issue as to why you're currently getting an infinite loop (more than likely something being freed when it shouldn't have if it's non-deterministic) |
This condition only applies once all the entries where iterated at least once, so wrapping around should'nt affect it. Ofc it might be that the dict is shrunken when it should'nt leading to there being no elements "free" as in no key and no value. |
Ah yes sorry you're right the count would have to be the full size of the internal list. Yeah I'd like to do a little more research into this as if this is an issue here (as in finding elements in the dict) it would be an issue with the internal Table type that came from craftinginterpreters which could be a much bigger issue as this type is used throughout the codebase. Many thanks for the PR and the really detailed issue by the way! |
@Jason2605 Apologies it took a while i had to do some debugging but heres a deterministic example to correctly and always reproduce the deadlock:
Maybe that can help. |
Thank you so much for the simpler reproduction this will help me a lot!! |
Okay yeah, so the issue is the fact that the count is being lowered but tombstones are still technically a "value" and aren't cleared until the dictionary is resized. For dictionaries we probably want a track of |
Can you elaborate maybe on how to solve the issue the way you described, since i see two ways(unrelated of exposing the count as a public api):
|
The simplest solution in my eyes is to have an extra Add
Remove
|
Ive changed the pr to reflect the discussed changes, let me know if i missed anything! |
Thanks for this! |
fix: correctly return tombstone when theres no free element
The dict findDictEntry function did not correctly handle the case when, a dict had no "free" slot but had tombstones, it would loop forever.
Resolves: #726
What's Changed:
This fixes that by conditionally returning a tombstone when all other indexes where processed.
Type of Change:
Housekeeping: