-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[SR-10281] URLSession crash while handling basic authentication #2061
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
Conversation
@swift-ci test |
@saiHemak Can you please change the commit message so that it describes the problem/solution from a URLSession standpoint? |
05a5f42
to
a6226ab
Compare
@pushkarnk please review .. |
This probably fixes the issue reported here: https://twitter.com/mxcl/status/1111073495017029635 |
LGTM |
@swift-ci please test and merge |
@saiHemak @pushkarnk Should this be back ported to 5.0? |
Yes definitely - PR coming v. soon :) |
Foundation: backport swiftlang/swift-corelibs-foundation#2061
Should this be fixed in docker image swift:5.0.1-bionic? I've got an API testing tool that specifically triggers 401s for testing purposes and between 5.0 and 5.0.1 I see some change in the output but I still seem to be getting the same underlying error: 5.0:
5.0.1:
This worked fine with swift:4.2.1. |
Raised #2063 against 5.0 branch |
I guess this isn't the full fix then... @finestructure can you provide your testcase? |
I'll try to isolate a test case! |
I've created a sample repo here: https://github.com/finestructure/SR-10281 and logged the test results to a file test.log Something odd seems to be going on (and I hope it's not me ;) ):
I hope that helps! |
Awesome, thanks so much. @pushkarnk is out today but we'll take a look ASAP. |
@finestructure Thanks for the test case. With With I see that the images |
Sorry, I meant to add to this yesterday and completely forgot: It appears that 5.0.1 fixes the fatal error that 5.0 introduced (line 50 in the test.log) but it doesn't seem to restore the 4.2.1 behaviour or match the 5.0/5.0.1 behaviour on macOS, which is to yield a response that is not In other words, I would have expected line 33 in that log not to be Does that make sense? |
Regarding your other comment
that doesn't match what I'm seeing:
I can confirm that I see the fatal error only with |
When you say "I also ran the test on Ubuntu 18.04 and 16.04 boxes" it seems like we're running the test differently. It sounds like you're not using docker but running I'm running the tests via the official swift docker images. If you've got docker installed, you can run all the tests and recreate my exact scenario if you run |
Hi @finestructure I did run with the official docker images using |
Ah , ok. So this seems to be the problem. Thanks for clarifying! |
The version reports correctly for me:
But after clearing my image I also get 5.0.1 now. Has the official version be retagged in docker hub?!
|
|
Ok, so the problem now is the inconsistency between versions |
@ianpartridge I see, thanks! Since there is no 5.0.0 image I'd assumed that's the one that's frozen. Maybe there should be one? |
Yes probably we should have done a |
Ok, I've filed it here: https://bugs.swift.org/browse/SR-10602 |
Basically the crash in URLSession code is due to the invocation of
TaskRegistry.remove
twice with the sametaskIdentifier
fromurlProtocolDidFinishLoading
. While handling basic authentication, if the response code is401
and authentication headers are missing then call should fail with errorurlProtocol(_ protocol: URLProtocol, didFailWithError error: Error)
which a is performing the removal oftask`` from
TaskRegistry. Hence, adding the
return``` statement after the above call should resolve the issue.