You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segfault when using enumFromTo with maxBound as upper bound #188
importqualifiedData.VectorasVimportData.Wordmain::IO()
main = (V.enumFromTo (predmaxBound) maxBound::V.VectorWord8) `seq`return()
$ cabal --version
cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.1
This only happens with optimizations enabled for me. Looking at the core it seems like what's happening is the counter from 0 to 255 is being incremented by one and then being compared with <= to 255. I think that the counter is overflowing back to 0 and so the code writes past the end of the allocated vector (which I checked is correctly allocated to 256 elements).
I also get a segmentation fault from this simpler code:
main::IO()
main =dolet t =V.enumFromTo255255::V.VectorWord8
t `seq`putStrLn"Thawing succeeded"
I updated the ticket title because this isn't specific to thaw, or to Word8, it is reproducible with Word16, Word32, etc as long as the upper bound is set to maxBound
Do we know what's broken? Tracing along the enumFromTo implementation, I get to a corresponding function on (monadic) bundles. But that just calls fromList [x .. y].
Activity
glguy commentedon Nov 30, 2017
This only happens with optimizations enabled for me. Looking at the core it seems like what's happening is the counter from 0 to 255 is being incremented by one and then being compared with
<=to 255. I think that the counter is overflowing back to 0 and so the code writes past the end of the allocated vector (which I checked is correctly allocated to 256 elements).I also get a segmentation fault from this simpler code:
[-]Segfault when thawing enumFromTo of Word8's[/-][+]Segfault when using enumFromTo with maxBound as upper bound[/+]glguy commentedon Nov 30, 2017
I updated the ticket title because this isn't specific to thaw, or to Word8, it is reproducible with Word16, Word32, etc as long as the upper bound is set to
maxBoundnoughtmare commentedon Nov 30, 2017
I have also updated the code.
dolio commentedon Dec 10, 2017
Do we know what's broken? Tracing along the
enumFromToimplementation, I get to a corresponding function on (monadic) bundles. But that just callsfromList [x .. y].Is it
unstreamthat's broken?glguy commentedon Aug 24, 2018
The bug is in this code: https://github.com/haskell/vector/blob/master/Data/Vector/Fusion/Bundle/Monadic.hs#L758-L767
Specifically the
+1on this line is overflowing.https://github.com/haskell/vector/blob/master/Data/Vector/Fusion/Bundle/Monadic.hs#L766
The bug is also present in the specialized code for
Inthttps://github.com/haskell/vector/blob/master/Data/Vector/Fusion/Bundle/Monadic.hs#L809-L824
cartazio commentedon Jul 12, 2019
booo, this needs to be fixed, adding to action list :)
cartazio commentedon Jan 21, 2020
brr, this has been languishing for too long
Add regression test for haskell#188
Add regression test for haskell#188
Add regression test for #188
cartazio commentedon Jan 31, 2020
this should be resolved in master now