swiftlang / swift-corelibs-foundation

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

[SR-2631] URLSession crash #3934

Closed pushkarnk closed 8 years ago

pushkarnk commented 8 years ago
Previous ID SR-2631
Radar None
Original Reporter @pushkarnk
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Foundation | |Labels | Bug | |Assignee | @pushkarnk | |Priority | Medium | md5: 59274b0cf31701712b31415379d31d57

Issue Description:

The following code hits a Trace/breakpoint trap

import Foundation
import Dispatch

func run() {
    var request = URLRequest(url: URL(string: "http://httpstat.us/200")!)
    request.httpMethod = "GET"
    print("req: \(request.description)")
    let session = URLSession(configuration: .default)
    let task = session.dataTask(with: request) { data, response, error in
        print("response: \(response)")
    }
    task.resume()
}

run()
dispatchMain()
pushkarnk commented 8 years ago

Here's the back trace:

#​0  0x00007ffff7d0dacd in ?? () from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libswiftCore.so
#​1  0x00007ffff75b3459 in _TTSf4g_n___TFC10Foundation14URLSessionTaskP33_655ABFF49E18DABF12076554C1107FC416startNewTransferfT4withVS_10URLRequest_T_ ()
   from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libFoundation.so
#​2  0x00007ffff75a3864 in _TFC10Foundation14URLSessionTaskP33_655ABFF49E18DABF12076554C1107FC413performResumefT_T_ ()
   from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libFoundation.so
#​3  0x00007ffff75a37fe in _TFFFC10Foundation14URLSessionTask6resumeFT_T_U_FT_T_U_FT_T_ ()
   from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libFoundation.so
#​4  0x00007ffff7eeb8b7 in _dispatch_call_block_and_release () from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libdispatch.so
#​5  0x00007ffff7ef7d71 in _dispatch_queue_serial_drain () from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libdispatch.so
#​6  0x00007ffff7ef83b1 in _dispatch_queue_invoke () from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libdispatch.so
#​7  0x00007ffff7efa429 in _dispatch_root_queue_drain () from /root/pushkar/nsurlsession/tests/usr/lib/swift/linux/libdispatch.so
#&#8203;8  0x00007ffff7f21bf8 in overcommit_worker_main (unused=<optimized out>)
    at /root/pushkar/nsurlsession/swift-corelibs-libdispatch/libpwq/src/posix/manager.c:287
#&#8203;9  0x00007ffff6d3a6aa in start_thread (arg=0x7fffe6ffd700) at pthread_create.c:333
#&#8203;10 0x00007ffff5dc813d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
pushkarnk commented 8 years ago

Submitted a PR: https://github.com/apple/swift-corelibs-foundation/pull/640