I'm seeing segfaults when using decimal with large numbers, particularly in interpreted code. I first noticed the problem under GHC 7.8.2, and it persists with GHC 7.8.3. Text version is 1.2.0.0.
The attached should segfault without output if compiled and run, and segfault after some small quantity of output if interpreted (I've seen just ", as well as "2"). . I have had similar failures with numbers as small as 3 * (fromIntegral (maxBound :: Int) :: Integer); however, it sometimes takes 2-3 evaluations in GHCI to segfault. Conversely, the following fails consistently.
import Data.Text.Lazy.Builder (toLazyText)
import Data.Text.Lazy.Builder.Int (decimal)
main = print (toLazyText (decimal 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002))
This is possibly a compiler issue, as I've received 'internal error: stg_ap_p_ret' from GHCI while playing with it. I haven't been able to reproduce that, so I'm bouncing it here first.
This seems to be in toLazyText or decimal, as simply packing the large decimal value from a string with Data.Text.Lazy.pack and printing it does not cause a problem.
I'm seeing segfaults when using
decimalwith large numbers, particularly in interpreted code. I first noticed the problem under GHC 7.8.2, and it persists with GHC 7.8.3. Text version is 1.2.0.0.The attached should segfault without output if compiled and run, and segfault after some small quantity of output if interpreted (I've seen just
", as well as"2"). . I have had similar failures with numbers as small as3 * (fromIntegral (maxBound :: Int) :: Integer); however, it sometimes takes 2-3 evaluations in GHCI to segfault. Conversely, the following fails consistently.This is possibly a compiler issue, as I've received 'internal error: stg_ap_p_ret' from GHCI while playing with it. I haven't been able to reproduce that, so I'm bouncing it here first.
This seems to be in
toLazyTextordecimal, as simply packing the large decimal value from a string withData.Text.Lazy.packand printing it does not cause a problem.