-
Notifications
You must be signed in to change notification settings - Fork 189
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
Work around GHC bug #12020 #192
Conversation
I was able to reproduce the crash on GHC 7.10.3 but not on GHC 8.0.1. Would be interesting to see if you can reproduce it on GHC 8.0.1 Anyway, I did some debugging by compiling all libraries with debug information, using the following command-line:
I then ran the crashing application inside gdb which gave me the following info:
Which seems to point to this source-location: https://github.com/vincenthz/hs-asn1/blob/master/data/Data/ASN1/Get.hs#L101 I also looked up I'd guess that the bug is in the file I linked to, but the line number is probably wrong. I'm not sure if it's really worth investigating further if the bug doesn't occur in GHC 8.0.1. |
I tracked down the bug and reported it: vincenthz/hs-asn1#17 |
So just to confirm: This PR does not provide a complete workaround, but prevents the common case? |
It should work around #12010 completely. If Holger is right, then the crash On Fri, Jun 3, 2016, 8:15 AM Evan Borden [email protected] wrote:
|
@enolan My only concern with this PR is that there is a fair amount of re-factoring that is intermixed with your work-around. I'm in favour of the de-duplication and clean up that you've done, but I'd like to see it migrated to another PR that we can merge before this one. That way your work-around is isolated in a single commit without ambiguity. |
Pulling off DRAFT and requesting merge. With the bug in hs-asn1 fixed I don't get crashes anymore. Thanks to @hreinhardt and @vincenthz for that. |
@enolan Can you bump this PR to get the new windows CI to run? @kazu-yamamoto Do you have any strong opinions here? |
Due to GHC bug #12010, on x86_64 Windows, in the threaded RTS, the return values of recv and send aren't checked properly in readRawBufferPtr or writeRawBufferPtr. Calls that return -1 are interpreted as returning 4,294,967,295 which is then converted back to a 32 bit int equal to -1. This occurs on all release versions of GHC. This patch adds tests that run obviously wrong operations and checks that they throw exceptions.
Makes the tests in the previous commit pass.
Passing :) |
Sorry but I have no opinions about Windows. |
Okay, with no objections I'm merging this. Thanks @enolan. |
Thanks @eborden ! |
This PR tries to work around GHC bug #12010, where calls to
readRawBufferPtr
andwriteRawBufferPtr
fail to throw exceptions on Windows 64 bit. I wrote tests, and patchedrecvBuf
andsendBuf
to make them pass. Unfortunately, I can still get a segfault on my outside test with artificial network corruption some of the time - somewhere less than 1.5%. The test program downloads a small package from FP Complete's Hackage mirror over TLS. If anyone can explain it, I'd be grateful. If not, this PR makes the crash much more rare anyway.To reproduce the crash:
git clone -b network-pr https://github.com/enolan/http-conduit-crash-hang.git
git clone https://github.com/enolan/findcrash.git
stack build
both of thosefindcrash
with the location ofbad-memcpy-crash
from thehttp-conduit-crash-hang
repo as its argument and wait a bit. It'll run the program until it crashes or 200 times, whichever comes first.You should get the Windows dialog box for a segfault: "bad-memcpy-crash.exe has stopped working".
Here's what I know:
recv
orsend
. It's either a new bug I introduced when I fixed the first one, or was always there.recv
, not during them. I've only seen it happen after TLS handshaking was done, but that may be chance.I hope a fresh set of eyes sees something. Maybe in the refactoring.
Best,
Echo