Opened 2 years ago

Closed 2 years ago

#5671 closed bug (fixed)

ghc-7.2 vector code segfaults

Reported by: kosmikus Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.2.1
Keywords: Cc: hvr@…
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Runtime crash Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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, but I'm not sure.

Change History (2)

comment:1 Changed 2 years ago by hvr

  • Cc hvr@… added

I can confirm this still occurs on ghc-7.3.20111130/x86_64 as well...

comment:2 Changed 2 years ago by kosmikus

  • Resolution set to fixed
  • Status changed from new to closed

This seems to have been fixed by the fix to bug #5658, at least I can't reproduce the problem with the latest snapshot. I'm closing this for now.

Note: See TracTickets for help on using tickets.