#3486: Data.ByteString.elemIndices causes SEGV
--------------------+-------------------------------------------------------
Reporter: nwn | Owner:
Type: bug | Status: new
Priority: normal | Component: libraries/base
Version: 6.10.4 | Severity: normal
Keywords: | Testcase:
Os: MacOS X | Architecture: x86
--------------------+-------------------------------------------------------
The elemIndices for strict ByteString causes SEGV in some situation.
{{{
import Data.Int
import qualified Data.ByteString as S
main = do
cs <- S.getContents
let ps = S.elemIndices 10 cs
putStrLn $ "S.length cs = " ++ show (S.length cs)
putStrLn $ "length ps = " ++ show (length ps)
}}}
If above program gets some large input, it crashes.
{{{
$ ghc --make ei
[1 of 1] Compiling Main ( ei.hs, ei.o )
Linking ei ...
$ yes | head -10000 | ./ei
S.length cs = 20000
Segmentation fault
}}}
By the way, there might be a border of SEGV or not.
{{{
$ yes | head -4096 | ./ei
S.length cs = 8192
Segmentation fault
$ yes | head -4095 | ./ei
S.length cs = 8190
length ps = 4095
}}}
And this script works fine.
{{{
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
main = do
let cs = S.pack . take 8192 . cycle $ [48,10]
ps = S.elemIndices 10 cs
putStrLn $ "length cs = " ++ show (S.length cs)
putStrLn $ "length ps = " ++ show (length ps)
}}}
I think there is causes about the bug in S.getContents or S.elemIndices or
both. But I cannot figure out it.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3486>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs