Skip to content

Segfault with Data.Text.Lazy.Builder.Int(decimal) #99

Description

@argiopetech

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions