Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Connection-0.2.6 breaks Amazonka (stackage lts-6.12 on up) #23

Closed
dysinger opened this issue Sep 2, 2016 · 17 comments
Closed

Connection-0.2.6 breaks Amazonka (stackage lts-6.12 on up) #23

dysinger opened this issue Sep 2, 2016 · 17 comments
Labels

Comments

@dysinger
Copy link

dysinger commented Sep 2, 2016

I tracked this down over the last full day of pulling my hair. It was not unlike the bug seen in hs-tls 1.3.4 where you would get bad mac every once in a while.

With connection-0.2.5 I can pound away on amazonka. With connection-0.2.6 I get random bad mac errors.

user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624                               
.....................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  3.27s user 0.99s system 20% cpu 21.052 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
........................................................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  5.08s user 1.31s system 11% cpu 56.224 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
........................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  3.28s user 0.95s system 17% cpu 24.207 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
............................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  3.15s user 0.87s system 14% cpu 27.544 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
.........................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  3.27s user 0.75s system 15% cpu 25.356 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
.................................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  3.18s user 1.00s system 12% cpu 33.218 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
..................................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  2.50s user 1.00s system 10% cpu 34.065 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
........................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  2.58s user 0.75s system 13% cpu 24.302 total
user@computer:~/src/github.com/fpco/ops% time stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624
........................ops: TransportError (TlsExceptionHostPort (Terminated True "received fatal error: BadRecordMac" (Error_Protocol ("remote side fatal error",True,BadRecordMac))) "s3.amazonaws.com" 443)
stack exec -- ops aws s3 purge 222b3ebc-70a0-11e6-80be-0f425a3fa624  2.22s user 0.84s system 12% cpu 24.030 total
@dysinger
Copy link
Author

dysinger commented Sep 2, 2016

lts-6.11 completes without error for my project

% diff <(stack --resolver=lts-6.11 list-dependencies) <(stack --resolver=lts-6.12 list-dependencies) 
43c43
< connection 0.2.5
---
> connection 0.2.6

@vincenthz
Copy link
Owner

vincenthz commented Sep 2, 2016

Sorry for your hair !
could you try with the latest cryptonite commit 8908af32168f6676b8f98b509ab5376706ab5660 to see if that works for you ?

@dysinger
Copy link
Author

dysinger commented Sep 3, 2016

My hair is ok :) Here's a script that will reproduce

#!/usr/bin/env stack
-- stack --resolver lts-6.12 --install-ghc runghc --package conduit --package lens --package amazonka --package amazonka-s3

{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Lens
import Control.Monad.IO.Class
import Data.Conduit
import qualified Data.Conduit.List as CL
import Data.Monoid
import Data.String
import Data.Foldable
import Data.Text (Text)
import qualified Data.Text.IO as TI
import Network.AWS
import Network.AWS.Data
import Network.AWS.S3

main = do
    env <- newEnv NorthVirginia Discover
    let say = liftIO . TI.putStrLn
        val
            :: ToText a
            => Maybe a -> Text
        val = maybe "Nothing" toText
        lat v = maybe mempty (mappend " - " . toText) (v ^. ovIsLatest)
        key v = val (v ^. ovKey) <> ": " <> val (v ^. ovVersionId) <> lat v
    runResourceT . runAWS env $
        do say "Listing Buckets .."
           bs <- view lbrsBuckets <$> send listBuckets
           say $ "Found " <> toText (length bs) <> " Buckets."
           forM_ bs $
               \(view bName -> b) -> do
                   say $ "Listing Object Versions in: " <> toText b
                   paginate (listObjectVersions b) =$=
                       CL.concatMap (view lovrsVersions) $$
                       CL.mapM_ (say . mappend " -> " . key)

Run it against any AWS account with some buckets & objects. After about 30 seconds or so it'll crash.

@dysinger
Copy link
Author

dysinger commented Sep 3, 2016

change the script to lts-6.11 and it'll work fine

@erikd
Copy link
Contributor

erikd commented Sep 4, 2016

I wonder if this is related to erikd-ambiata/test-warp-wai#1 (comment) ?

@dysinger
Copy link
Author

dysinger commented Sep 6, 2016

Looks similar @erikd

@dysinger
Copy link
Author

dysinger commented Sep 6, 2016

snoyberg/http-client#225

@vincenthz
Copy link
Owner

dysinger: I'm not sure how to test this script with a non-released version of cryptonite, any idea ?

@vincenthz vincenthz added the bug label Sep 10, 2016
@erikd
Copy link
Contributor

erikd commented Sep 13, 2016

I've tried recreating my issue just using the connection library talking to HTTP and HTTPS servers. Was not able to find anything, suggesting that this was actually a problem with http-client.

@vincenthz
Copy link
Owner

@erikd: I don't think that's the case, definitely a low level crypto issue. did you use the git version of cryptonite ?

@erikd
Copy link
Contributor

erikd commented Sep 13, 2016

Nope, used the 0.19 release version.

@vincenthz
Copy link
Owner

@erikd I don't think you have the same issue than @dysinger here, this is the BadRecordMac issue

@erikd
Copy link
Contributor

erikd commented Sep 13, 2016

Ah ok, may be a different issue.

@vincenthz
Copy link
Owner

vincenthz commented Mar 14, 2017

is this still a bug ? (both connection and tls has new revisions since)

@erikd
Copy link
Contributor

erikd commented Mar 14, 2017

Its still a HANDLE leak as far as I can tell. I tried it with connection 2.7 about a month ago.

I can test again (tomorrow) if you let me know what versions I should be testing.

@vincenthz
Copy link
Owner

that sounds like a different bug from the BadRecordMac

@erikd
Copy link
Contributor

erikd commented Mar 15, 2017

Opened #29 .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants