[Haskell-cafe] FFI problem - possibility of CStringLen overflow?
greenrd at greenrd.org
Sun Jul 19 22:24:49 EDT 2009
While rewriting cautious-file to use ByteStrings and FFI just now, I
came across this potential problem:
Why does the FFI specification define CStringLen as (Ptr CChar, Int)?
As the FFI specification itself notes, Haskell 98 implementors are
allowed to have a quite small range for Int (only up to 2^29-1) - so you
could in principle have a very large String which cannot be represented
as a CStringLen, or a very large CString which cannot be represented as
a CStringLen. They would take up wads of memory, so this has probably
never happened yet, but it's in principle possible, no?
If so, what are the implications of this for code correctness?
More information about the Haskell-Cafe