ghc-7.2 vector code segfaults
The following program segfaults on x86_64 with vector-0.9
- with ghc-7.2.1 and -O
- with ghc-7.2.2 and -O
- with ghc-7.3.20111122 and -O
I does not segfault with ghc-7.0.4 or without -O.
It also segfaults on x86 if I change the number from 965 to 1934. I haven't thoroughly tested this, but these seem to be the smallest numbers each for which there is a segfault.
import qualified Data.Vector as U
main :: IO ()
main =
f (U.fromList (replicate 965 (((), ()), ())))
`seq` return ()
f x = g (fst (U.unzip x))
g x = U.zipWith (flip const) x (h (fst (U.unzip x)))
h x = U.zipWith op y x
where y = U.zipWith op x (U.init z)
z = U.generate (n+1) (\ i -> x U.! (if i >= n then n - 1 else i))
n = U.length x
op () () = ()
By looking at Core code a bit and comparing output from 7.0.4 and 7.2.2, I see reversed array indexing and bounds checking. So it looks like this might be related to bug #5658 (closed), but I'm not sure.
Trac metadata
Trac field | Value |
---|---|
Version | 7.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |