haskell-repa / repa

High performance, regular, shape polymorphic parallel arrays.
repa.ouroborus.net
138 stars 36 forks source link

Arbitrary crashes at size 0 #12

Closed Lysxia closed 6 years ago

Lysxia commented 7 years ago

The instance Arbitrary (a :. Int) expects the size parameter n to be positive. Tests then crash because QuickCheck's test drivers start with size 0.

Lysxia commented 7 years ago

Source of the bug

If n = 0, b may be 0. Then we have ceiling NaN which has no semantics. With optimizations, which repa enables, ceiling NaN is an absurd negative number (at least on my 64bit x86 machine), causing resize to crash.

FYI without optimizations ceiling NaN = 0 and things somehow work out, causing some headscratching when trying to analyze the bug.