HSCountingInputStream
HSCountingInputStream copied to clipboard
Getting EXC_BAD_ACCESS exception
I'm getting an EXC_BAD_ACCESS exception at
(BOOL)_setCFClientFlags:(CFOptionFlags)inFlags callback:(CFReadStreamClientCallBack)inCallback context:(CFStreamClientContext *)inContext
in HSRandomDataInputStream on
copiedCallback((CFReadStreamRef)CFBridgingRetain(self), kCFStreamEventHasBytesAvailable, &copiedContext);
Do you have an idea?
I also have this issue when I try to use the HSRandomDataInputStream with Alamofire's upload and to an HTTPS url; it works with an HTTP url though; very strange?
I think some of the innards aren't necessarily set up yet when _setCFClientFlags first gets invoked on certain systems (I'm seeing this on macOS 10.14, but not 10.15). The copiedCallback invocation doesn't seem to be necessary here anyway, and this fork does away with it. I'll submit a PR.
Actually I'll leave the PR to someone else, but if you're only integrating with NSUrlSessions then you can skip all the callback invocations (in both read and setCFClientFlags).
Otherwise you'll need to be able to turn that on and off depending on the context. Look at https://github.com/pavelosipov/POSInputStreamLibrary for inspiration!