Swift 4:Linux上的多网络请求

Swift 4:Linux上的多网络请求,swift,linux,urlrequest,urlsession,Swift,Linux,Urlrequest,Urlsession,我多次尝试发出网络请求,但在linux上遇到错误core-dumpederror(macOS正常) request1()或request2()被中止 import Foundation import Dispatch func request2() { for i in 1...5 { var request = URLRequest(url: URL(string: "https://jsonplaceholder.typicode.com/todos/1")!)

我多次尝试发出网络请求,但在linux上遇到错误
core-dumped
error(macOS正常)

request1()
request2()
被中止

import Foundation
import Dispatch

func request2() {
    for i in 1...5 {
        var request = URLRequest(url: URL(string: "https://jsonplaceholder.typicode.com/todos/1")!)
        request.httpMethod = "POST"
        let sessionConfiguration = URLSessionConfiguration.default
        let session = URLSession(configuration: sessionConfiguration)
        session.dataTask(with: request) {data, response, err in
            print("Entered the completionHandler")
        }.resume()
    }
}


func request1() {
    for i in 1...5 {
            let imgURL = URL(string: "https://upload.wikimedia.org/wikipedia/commons/0/07/Huge_ball_at_Vilnius_center.jpg")!
            let _ = try! Data(contentsOf: imgURL)
            print("\(i) completed downloading")
    }
}

request2()
//request1()

dispatchMain()
有时它会运行,但最常见的行为是出现以下错误:

情况1:它执行4次,然后中止

Entered the completionHandler
Entered the completionHandler
Entered the completionHandler
Aborted (core dumped)
情况1:它执行1次,然后中止并显示一堆错误

*** Error in `./.build/debug/teste': double free or corruption (fasttop): 0x00007f84000009b0 ***
Entered the completionHandler
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f841d1717e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f841d17a37a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f841d17e53c]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x4ee7c)[0x7f841f5a9e7c]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x48e0c)[0x7f841f5a3e0c]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x49c82)[0x7f841f5a4c82]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x44125)[0x7f841f59f125]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x445b1)[0x7f841f59f5b1]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x4aded)[0x7f841f5a5ded]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x4ad1e)[0x7f841f5a5d1e]
/root/swift-4.0-RELEASE-ubuntu16.04/usr/lib/swift/linux/libdispatch.so(+0x46df8)[0x7f841f5a1df8]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f841e1736ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f841d2013dd]
======= Memory map: ========
00400000-00403000 r-xp 00000000 fd:01 1555082                            /root/swift-apps/teste/.build/x86_64-unknown-linux/debug/teste
00403000-00404000 r--p 00002000 fd:01 1555082                            /root/swift-apps/teste/.build/x86_64-unknown-linux/debug/teste
00404000-00405000 rw-p 00003000 fd:01 1555082                            /root/swift-apps/teste/.build/x86_64-unknown-linux/debug/teste
017d8000-018ad000 rw-p 00000000 00:00 0                                  [heap]
7f83d8000000-7f83d8021000 rw-p 00000000 00:00 0
7f83d8021000-7f83dc000000 ---p 00000000 00:00 0
7f83e0000000-7f83e0021000 rw-p 00000000 00:00 0
7f83e0021000-7f83e4000000 ---p 00000000 00:00 0
...
7fff08581000-7fff085a2000 rw-p 00000000 00:00 0                          [stack]
7fff085f1000-7fff085f3000 r--p 00000000 00:00 0                          [vvar]
7fff085f3000-7fff085f5000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted (core dumped)
环境:

Swift 4.0
Ubuntu: 16.04

有人能帮我吗?

我有同样的问题,但还没有找到解决方案。看起来这已经被报告为一个错误:可能会在Swift 4.0.1中修复