-
Notifications
You must be signed in to change notification settings - Fork 123
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
An admittedly malicious core dump #73
Comments
Perhaps we should embed some sensible side-conditions in the type checker, @yav ? |
I don't think this has anything to do with the type checker:
If I had to guess, I'd say it's probably the pretty-printer choking as it's trying to print such a large literal with enough 0's and such.. |
You are right. Watch that heap size grow when trying to pretty-print. @brianhuffman or @acfoltzer, can you have a look? |
Even without pretty printing, any use of numeric literals at multi-billion-bit sizes will use a lot of memory. Ten billion bits will fit, but will allocate a significant percentage of my system memory. 100 billion is too much.
The memory is apparently demanded by function What exactly is the desired behavior here? Should the interpreter be designed to work with bitvectors too large to fit in system memory? With some kind of sparse representation it might be possible, but that seems like a lot of work for a small reward. Giving up with an out-of-memory error seems like a pretty reasonable behavior to me; perhaps we should just aim to handle the out-of-memory exception and stay in the REPL. |
My thought was your last one - return to the REPL rather than aborting. On Sat, Sep 13, 2014 at 4:49 PM, brianhuffman [email protected]
|
I'm not sure there's much hope for staying in the REPL after running out of memory: ghc's runtime doesn't seem to throw a catchable out-of-memory exception. Creating 100-billion-bit integers in ghci causes it to exit, just as cryptol does:
Bit sizes larger than a certain threshold (just below 2^37) cause the gmp error instead:
Maybe we should pass along this issue to the ghc maintainers. |
Seems like it's not Cryptol's fault. Do you know the folks to pass it along On Sat, Sep 13, 2014 at 5:48 PM, brianhuffman [email protected]
|
@yav is the primary ghc developer in our office; he probably knows who to get in touch with. |
There is apparently a hard-coded call to |
I don't think we plan on doing any homomorphic crypto in Cryptol any day soon, but we certainly would like to do RSA sooner rather than later. I would be comfortable with a smart guard on such actions that just looks at the system config and ball-parks on the maximum usable value bit size (while emitting a warning). |
They don't appear to address this straightforwardly in the GMP documentation, but per wikipedia:
The question is where to enforce this limit. Perhaps in the typechecker, if any monomorphic word type is that large, we could bail out? It seems a bit hackish to reject programs that should be able to typecheck, but if the alternative is to crash (gracefully or not) when evaluating, it seems like the better option. I'll try adding this and see how it goes. |
If we're restricted to small numbers in the type checker, will the following work as a type constraint (it currently does):
From the Salsa20 spec (pdf): "Let m be an l-byte sequence for some l ∈ {0, 1, . . . , 2^70}" I always liked having that constraint as documentation. Though now that I look, I see it is missing from the |
I would vote for having the typechecker accept programs that use very large bitvector sizes, and instead have the evaluator fail gracefully with a nice error message when very large sizes come up. One reason is that other backends (e.g. SMT solvers) might be able to handle huge sizes just fine:
|
With version 2.0.0 (ceb084c)
Cryptol> 1:[100000000000]
cryptol2: out of memory (requested 12500074496 bytes)
Cryptol> 1:[11111111111111]
gmp: overflow in mpz type
Aborted (core dumped)
The text was updated successfully, but these errors were encountered: