-
Notifications
You must be signed in to change notification settings - Fork 53
generation problems with Arena::clear() and Arena::drain(), and other drain() problems #30
Comments
Thanks for filing a bug report! Are you interested in making a PR to add these generation bumps? |
I'm not familiar enough with the crate to be sure it's the right solution:
If you're nevertheless interested in a PR that does nothing except the bare minimum right now (bump generation in these two spots), I could make one. :-) ETA: For the more serious drain() issue, it might be possible to PPYP by setting arena.len to 0 and arena.free_list_head to None before invoking Vec::drain(). I don't know if this will really work, or if it's the best thing. It might be better to give up on using Vec::drain() and "just" implement a drain() which turns Occupied entries into Free ones as it iterates through them. But this is above my pay grade; I wouldn't feel confident trying to implement either one of these solutions. |
I was just bit by this bug from an |
Looking at the code I was a bit surprised to see that Arena's generation isn't incremented each time an element is inserted; rather, it's incremented only when an item is removed. So generation doesn't climb quite as quickly as it would have, which is nice; but also, there are more special cases. Some of them aren't handled properly:
While checking 2., I hit another bug with drain():
Here is some code which I added to the end of the example from README.md, to demonstrate the problems:
With this code added, the example generates the following output:
The text was updated successfully, but these errors were encountered: