Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,929
    • Issues 4,929
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 461
    • Merge requests 461
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #3486
Closed
Open
Created Sep 03, 2009 by nwn@trac-nwn

Data.ByteString.elemIndices causes SEGV

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.

Trac metadata
Trac field Value
Version 6.10.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking