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
Segfault in Weak.get_copy with Infix_tag #9485
Comments
I'd forgotten about that one! This is a different Infix_tag bug, though - Weak.get_copy's reimplementation of |
Do you think it is possible to directly call the code of |
Looking at it, I think there are enough differences that this would be awkward. I think our best option might be to deprecate get_copy and make it be an alias for get - I don't think the optimisation it enables is really helpful any more. |
I don't see what changed from when the optimisation was added. It is useful except in OCaml stdlib in weakhashset and weakhashtbl, in order to not make alive a value just to see it fail the equality test:
Still I really don't like (hate?) |
When the optimisation was added, an equality comparison was done whenever two keys ended up in the same bucket, which happens regularly. These days, and equality comparison is only done if two keys have exactly the same hash (not just bucket), which is very rare. |
Indeed, I misremember the history. The weak hashtables were added in 0032c48, the use of the hash has been added many years later in db20929 (and described in Hashconsing in an Incrementally Garbage-Collected System by @damiendoligez and @pascal-cuoq). So are you going to propose the removal of this function, at least from its use in weak hashtbl and deprecation? |
The implementation of
Weak.get_copy
is missing the special case necessary to handleInfix_tag
, so it can corrupt memory:I don't think this is particularly urgent to fix, because it's been there a long time without anyone noticing:
The text was updated successfully, but these errors were encountered: