swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.29k stars 1.13k forks source link

[SR-10210] Swift 5 Foundation URLSession crash on Linux #3505

Open mxcl opened 5 years ago

mxcl commented 5 years ago
Previous ID SR-10210
Radar None
Original Reporter @mxcl
Type Bug
Environment - Ubuntu 16.04 - Swift 5.0.0 - cURL 7.61.0 - AWS t3.nano instance
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 2 | |Component/s | Foundation | |Labels | Bug, 5.0Regression | |Assignee | None | |Priority | Medium | md5: 54801e544c0d154f93c41690a150a82e

Issue Description:

Hey people, sorry to report I got this crasher in my server app with Swift 5.0.0:

“Fatal error: Trying to remove task, but it's not in the registry.: file /home/buildnode/jenkins/workspace/oss-swift-5.0-package-linux-ubuntu-16_04/swift-corelibs-foundation/Foundation/URLSession/TaskRegistry.swift, line 76”

I cannot offer more info right now, but will attempt to trace it better and supplement the report.

Never saw it with 4.x (was running with 4.x for \~5 months), and I did update to Swift 5 on Monday, so it seems Swift 5, but you will know better.

belkadan commented 5 years ago

@millenomi, who works on URLSession?

millenomi commented 5 years ago

cc ianpartridge (JIRA User)

swift-ci commented 5 years ago

Comment by Ian Partridge (JIRA)

https://github.com/apple/swift-corelibs-foundation/pull/1625 was supposed to fix this... 🙁

@mxcl - let us know if you find a recreate...

jdmcd commented 5 years ago

I just hit this on Linux as well. Unfortunately I can't figure out how to put together a recreate so I know this isn't super helpful but I thought I'd post here anyway.

jdmcd commented 5 years ago

So, I just put this test together:

/// Register your application's routes here.
public func routes(_ router: Router) throws {
    // Basic "It works" example
    router.get { req throws -> Future<String> in
        let client = try req.make(Client.self)
        return client.post("https://httpbin.org/anything", headers: ["X-API-KEY": "Test"]) { req in
            try req.content.encode(ContentTest(name: "Test"))
        }.transform(to: "Hello, World")
    }

    struct ContentTest: Content {
        let name: String
    }
}

I wasn't able to get it to crash on Linux in Docker, even though it's essentially doing the exact same thing my server is with a different URL. I'm not sure what's going on but it brought my server down multiple times today so I'm gonna roll back to 4.x for now.