GHC: Ticket #5671: ghc-7.2 vector code segfaults
http://ghc.haskell.org/trac/ghc/ticket/5671
<p>
The following program segfaults on x86_64 with vector-0.9
</p>
<ul><li>with ghc-7.2.1 and -O
</li><li>with ghc-7.2.2 and -O
</li><li>with ghc-7.3.20111122 and -O
</li></ul><p>
I does <em>not</em> segfault with ghc-7.0.4 or without -O.
</p>
<p>
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.
</p>
<pre class="wiki">
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 () () = ()
</pre><p>
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 <a class="closed ticket" href="http://ghc.haskell.org/trac/ghc/ticket/5658" title="bug: Strict bindings are wrongly floated out of case alternatives. (closed: fixed)">#5658</a>, but I'm not sure.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/5671
Trac 1.0.1hvrFri, 02 Dec 2011 10:07:17 GMTcc set
http://ghc.haskell.org/trac/ghc/ticket/5671#comment:1
http://ghc.haskell.org/trac/ghc/ticket/5671#comment:1
<ul>
<li><strong>cc</strong>
<em>hvr@…</em> added
</li>
</ul>
<p>
I can confirm this still occurs on ghc-7.3.20111130/x86_64 as well...
</p>
TicketkosmikusFri, 16 Dec 2011 16:13:23 GMTstatus changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/5671#comment:2
http://ghc.haskell.org/trac/ghc/ticket/5671#comment:2
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
</ul>
<p>
This seems to have been fixed by the fix to bug <a class="closed ticket" href="http://ghc.haskell.org/trac/ghc/ticket/5658" title="bug: Strict bindings are wrongly floated out of case alternatives. (closed: fixed)">#5658</a>, at least I can't reproduce the problem with the latest snapshot. I'm closing this for now.
</p>
Ticket