Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreproducible failure in Unicode.Stream test suite #2699

Open
harendra-kumar opened this issue Jan 25, 2024 · 0 comments
Open

Unreproducible failure in Unicode.Stream test suite #2699

harendra-kumar opened this issue Jan 25, 2024 · 0 comments
Labels
type:bug Does not work as expected
Milestone

Comments

@harendra-kumar
Copy link
Member

On GHC-8.6.5, in a PR based on 5d096df

Failures:

  Streamly/Test/Unicode/Stream.hs:177:9: 
  1) Unicode.Stream, UTF8 - Encoding / Decoding, Arrays Streamly.Data.String.lines == Prelude.lines
       Assertion failed (after 766 tests):
      zipAsyncly Compose three - empty in the middle [✔]
         [48,89,237,128,185,236,161,51,229,204,167,5,154,15,252,80,71,15,179,204]

  To rerun use: --match "/Unicode.Stream/UTF8 - Encoding / Decoding/Arrays Streamly.Data.String.lines == Prelude.lines/" --seed 1380626044
        +++ OK, passed 100 tests.

Randomized with seed 1380626044

The relevant test is:

testLinesArray :: Property
testLinesArray =
    forAll genWord8 $ \list ->
        monadicIO $ do
            xs <- Stream.toList
                    $ fmap A.toList
                    $ AS.splitOnSuffix 10
                    $ Stream.fromPure (A.fromList list)
            assert (xs == map (map (fromIntegral . ord))
                              (lines (map (chr .  fromIntegral) list)))

Could be an issue with AS.splitOnSuffix?

{-# INLINE splitOnSuffix #-}
splitOnSuffix
    :: (MonadIO m)
    => Word8
    -> Stream m (Array Word8)
    -> Stream m (Array Word8)
splitOnSuffix = Array.compactOnByteSuffix
{-# INLINE compactOnByteSuffix #-}
compactOnByteSuffix
    :: (MonadIO m)
    => Word8
    -> Stream m (Array Word8)
    -> Stream m (Array Word8)
compactOnByteSuffix byte =
    fmap unsafeFreeze . MA.compactOnByteSuffix byte . fmap unsafeThaw
{-# INLINE compactOnByteSuffix #-}
compactOnByteSuffix
    :: (MonadIO m)
    => Word8
    -> Stream m (MutArray Word8)
    -> Stream m (MutArray Word8)
compactOnByteSuffix byte =
        -- XXX use spliceExp and rightSize?
        Stream.splitInnerBySuffix
            (\arr -> byteLength arr == 0) (breakOn byte) splice

breakOn uses unpinned pointer in memcpy, could it be because of that?

@harendra-kumar harendra-kumar added the type:bug Does not work as expected label Jan 25, 2024
@harendra-kumar harendra-kumar added this to the 0.11.0 milestone Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Does not work as expected
Projects
None yet
Development

No branches or pull requests

1 participant