-
Notifications
You must be signed in to change notification settings - Fork 13
Type safety issue? #124
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
Comments
Use `WordPtr` instead of `Word` for `Nattish`. `Word` is actually fine, but I think `WordPtr` makes it more *obviously* fine, and also adds a bit of insurance against hypothetical future changes to GHC. Closes lspitzner#124.
I'm not sure this is actually a problem we need to solve. All the containers in |
You can make an enormous queue using |
The fake GADT we now use for maps and unordered traversals and folds is a little bit unsafe. I thought that we were well protected by the fact that the queue would have to reach$2^32$ words, if there are any such around. In particular, an adversary could calculate something like
O(2^WORDSIZE)
elements to cause a problem, but it's actually possible to do this in a reasonable amount of time on systems with 32-bitWord
but addressable memory considerably exceedingstimes (2^(2^32)) (singleton () ())
. This will take quite a long time, and something in excess of 64 gigabytes of memory, but I think it's possible in principle.Suppose someone uses
traverseU
on this monstrosity, with aBackwards
applicative. I suspect they will be able to actually reach the point where underflow occurs, leading to an unsafe coercion and memory fault.The easiest solution is to use$2^{2^{64}}$ by any means whatsoever. The downside is that this will hurt performance on 32-bit systems. I don't know how much we care.
Word64
instead ofWord
. I don't think it's realistic to produce a queue whose size exceedsThe other obvious solution is to make sure we never underflow. The best way to do that is probably to perform a size check on
insert
and onunion
. This has the side benefit of ensuring thatsize
always produces a correct value. The downside of course is that insertion becomes ever so slightly slower.The text was updated successfully, but these errors were encountered: