apple / swift-nio

Event-driven network application framework for high performance protocol servers & clients, non-blocking.
https://swiftpackageindex.com/apple/swift-nio/documentation
Apache License 2.0
7.98k stars 650 forks source link

[Concurrency] - Crash using `completeWithAsync` #1874

Closed 0xTim closed 3 years ago

0xTim commented 3 years ago

Expected behavior

Promise to return async result

Actual behavior

Crashes with NIO-ELT-0-#5 (8): EXC_BAD_ACCESS (code=1, address=0x0). Stacktrace is below. The code is:

    let eventLoop = EmbeddedEventLoop()
    let promise = eventLoop.makePromise(of: String.self)
    promise.completeWithAsync {
      await someString()
    }
    return promise.futureResult

Steps to reproduce

  1. git clone https://github.com/0xTim/AsyncCrash.git
  2. cd AsyncCrash
  3. swift run

SwiftNIO version/commit hash

2.29.0

Swift & OS version (output of swift --version && uname -a)

swift-driver version: 1.26 Apple Swift version 5.5 (swiftlang-1300.0.19.104 clang-1300.0.18.4)
Target: x86_64-apple-macosx11.0
Darwin Tims-Mac-mini.brokenhands.net 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64

Stacktrace

(lldb) bt all
  thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x00007fff2047dcde libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00000001032c0705 libsystem_pthread.dylib`_pthread_cond_wait + 1298
    frame #2: 0x000000010250370e libclang_rt.tsan_osx_dynamic.dylib`__tsan::call_pthread_cancel_with_cleanup(int (*)(void*), void (*)(void*), void*) + 62
    frame #3: 0x00000001024bd31d libclang_rt.tsan_osx_dynamic.dylib`wrap_pthread_cond_wait + 525
    frame #4: 0x00000001005730c3 Run`ConditionLock.lock(wantedValue=1, self=0x00007b0c00064ce0) at lock.swift:191:23
    frame #5: 0x0000000100436aac Run`EventLoopFuture.wait(file="/Users/timc/Library/Developer/Xcode/DerivedData/AsyncExample-dfwmoohbqguwxebfhgdjjsuhtjer/SourcePackages/checkouts/vapor/Sources/Vapor/Application.swift", line=100, self=0x00007b1400012480) at EventLoopFuture.swift:949:14
    frame #6: 0x0000000100007518 Run`Application.run(self=0x00007b38000001c0) at Application.swift:100:38
    frame #7: 0x000000010000495a Run`main at main.swift:9:9
    frame #8: 0x00007fff204cbf5d libdyld.dylib`start + 1
  thread #2
    frame #0: 0x00007fff2047dbb2 libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007fff203fdc2a libsystem_c.dylib`nanosleep + 196
    frame #2: 0x00007fff203fdb24 libsystem_c.dylib`usleep + 53
    frame #3: 0x00000001024f5764 libclang_rt.tsan_osx_dynamic.dylib`__tsan::BackgroundThread(void*) + 436
    frame #4: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #5: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #3, name = 'NIO-ELT-0-#0'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=3, changelist=nil, nchanges=0, eventlist=0x7b7000010000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=3, changelist=nil, nchanges=0, eventlist=0x7b7000010000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b1400012840) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400012840) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400012840) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c00007800, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c00007800) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c00051210, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c00051210, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b080002a360, _loop=0x00007b3c00007800, loopUpAndRunningGroup=0x00007b1400010860) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050c40) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #4, name = 'NIO-ELT-0-#1'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=4, changelist=nil, nchanges=0, eventlist=0x7b7000020000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=4, changelist=nil, nchanges=0, eventlist=0x7b7000020000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b1400014ff0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400014ff0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400014ff0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c0000fff0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c0000fff0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c00052fe0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c00052fe0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b080002a1a0, _loop=0x00007b3c0000fff0, loopUpAndRunningGroup=0x00007b14000107c0) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050c70) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #5, name = 'NIO-ELT-0-#2'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=5, changelist=nil, nchanges=0, eventlist=0x7b7000030000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=5, changelist=nil, nchanges=0, eventlist=0x7b7000030000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b14000177f0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b14000177f0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b14000177f0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c000177f0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c000177f0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c000547e0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c000547e0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b080002a020, _loop=0x00007b3c000177f0, loopUpAndRunningGroup=0x00007b1400010720) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050c10) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #6, name = 'NIO-ELT-0-#3'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=6, changelist=nil, nchanges=0, eventlist=0x7b7000040000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=6, changelist=nil, nchanges=0, eventlist=0x7b7000040000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b1400019ff0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400019ff0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400019ff0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c0001ffe0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c0001ffe0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c00055fe0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c00055fe0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b080002a0c0, _loop=0x00007b3c0001ffe0, loopUpAndRunningGroup=0x00007b1400010680) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050be0) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #7, name = 'NIO-ELT-0-#4'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=7, changelist=nil, nchanges=0, eventlist=0x7b7000050000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=7, changelist=nil, nchanges=0, eventlist=0x7b7000050000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b140001c7f0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140001c7f0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140001c7f0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c000277e0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c000277e0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c000577e0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c000577e0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b080002a040, _loop=0x00007b3c000277e0, loopUpAndRunningGroup=0x00007b14000105e0) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050bb0) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
* thread #8, name = 'NIO-ELT-0-#5', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff2cb94dc7 libswiftCore.dylib`swift::ResolveAsSymbolicReference::operator()(swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*) + 55
    frame #1: 0x00007fff2cbb72dd libswiftCore.dylib`swift::Demangle::__runtime::Demangler::demangleSymbolicReference(unsigned char) + 141
    frame #2: 0x00007fff2cbb42a8 libswiftCore.dylib`swift::Demangle::__runtime::Demangler::demangleType(__swift::__runtime::llvm::StringRef, std::__1::function<swift::Demangle::__runtime::Node* (swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*)>) + 168
    frame #3: 0x00007fff2cb9a5a4 libswiftCore.dylib`swift_getTypeByMangledNameImpl(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 516
    frame #4: 0x00007fff2cb97d6d libswiftCore.dylib`swift::swift_getTypeByMangledName(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 477
    frame #5: 0x00007fff2cb97f9b libswiftCore.dylib`swift_getTypeByMangledNameInContext + 171
    frame #6: 0x0000000100fa5c47 Run`__swift_instantiateConcreteTypeFromMangledName at <compiler-generated>:0
    frame #7: 0x0000000100fa598a Run`EventLoopPromise.completeWithAsync(body=0x1010099d0, self=NIO.EventLoopPromise<NIOHTTP1.HTTPResponseStatus> @ 0x00007e80003891c0) at AsyncAwaitSupport.swift:0
  * frame #8: 0x00000001000473c8 Run`closure #1 in closure #1 in RoutesBuilder.on<Self>(request=0x00007b44000201c0, closure=0x1010b7110) at RoutesBuilder+Concurrency.swift:135:29
    frame #9: 0x0000000100048054 Run`partial apply for closure #1 in closure #1 in RoutesBuilder.on<A>(_:_:body:use:) at <compiler-generated>:0
    frame #10: 0x0000000100047899 Run`thunk for @escaping @callee_guaranteed (@guaranteed ByteBuffer?) -> (@owned EventLoopFuture<A1>) at <compiler-generated>:0
    frame #11: 0x0000000100048124 Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed ByteBuffer?) -> (@owned EventLoopFuture<A1>) at <compiler-generated>:0
    frame #12: 0x000000010042bea6 Run`closure #1 in EventLoopFuture.flatMap<Value>(self=0x00007b1400020080, callback=0x1000480e0, next=NIO.EventLoopPromise<NIOHTTP1.HTTPResponseStatus> @ 0x00007e8000389630) at EventLoopFuture.swift:475:31
    frame #13: 0x00000001004355de Run`partial apply for closure #1 in EventLoopFuture.flatMap<A>(file:line:_:) at <compiler-generated>:0
    frame #14: 0x000000010042ca88 Run`EventLoopFuture._addCallback(callback=0x00000001004355b0, self=0x00007b1400020080) at EventLoopFuture.swift:701:16
    frame #15: 0x000000010042cc8a Run`EventLoopFuture._whenComplete(callback=0x00000001004355b0, self=0x00007b1400020080) at EventLoopFuture.swift:708:18
    frame #16: 0x000000010042b9af Run`EventLoopFuture.flatMap<Value>(file="/Users/timc/Library/Developer/Xcode/DerivedData/AsyncExample-dfwmoohbqguwxebfhgdjjsuhtjer/SourcePackages/checkouts/vapor/Sources/Vapor/Concurrency/RoutesBuilder+Concurrency.swift", line=133, callback=0x1000480e0, self=0x00007b1400020080) at EventLoopFuture.swift:472:14
    frame #17: 0x0000000100046a57 Run`closure #1 in RoutesBuilder.on<Self>(request=0x00007b44000201c0, body=collect, closure=0x1010b7110) at RoutesBuilder+Concurrency.swift:133:19
    frame #18: 0x0000000100046e2e Run`partial apply for closure #1 in RoutesBuilder.on<A>(_:_:body:use:) at <compiler-generated>:0
    frame #19: 0x000000010007e127 Run`BasicResponder.respond(request=0x00007b44000201c0, self=(closure = 0x0000000100046dc0 Run`partial apply forwarder for closure #1 (Vapor.Request) -> NIO.EventLoopFuture<Vapor.Response> in Vapor.RoutesBuilder.on<A where A1: Vapor.ResponseEncodable>(_: NIOHTTP1.HTTPMethod, _: Swift.Array<RoutingKit.PathComponent>, body: Vapor.HTTPBodyStreamStrategy, use: (Vapor.Request) async throws -> A1) -> Vapor.Route at <compiler-generated>)) at BasicResponder.swift:24:24
    frame #20: 0x000000010007e372 Run`protocol witness for Responder.respond(to:) in conformance BasicResponder at <compiler-generated>:0
    frame #21: 0x0000000100152ac2 Run`ErrorMiddleware.respond(request=0x00007b44000201c0, next=(payload_data_0 = 0x0000000100046dc0 Run`partial apply forwarder for closure #1 (Vapor.Request) -> NIO.EventLoopFuture<Vapor.Response> in Vapor.RoutesBuilder.on<A where A1: Vapor.ResponseEncodable>(_: NIOHTTP1.HTTPMethod, _: Swift.Array<RoutingKit.PathComponent>, body: Vapor.HTTPBodyStreamStrategy, use: (Vapor.Request) async throws -> A1) -> Vapor.Route at <compiler-generated>, payload_data_1 = 0x00007b1400011c60 -> 0x000000010119a238 Run`block_descriptor + 136, payload_data_2 = 0x0000000102502aac libclang_rt.tsan_osx_dynamic.dylib`__tsan::cur_thread() + 28, metadata = Vapor.BasicResponder, wtable = 0x000000010119b0a0 Run`protocol witness table for Vapor.BasicResponder : Vapor.Responder in Vapor), self=(closure = 0x0000000100152890 Run`partial apply forwarder for closure #1 (Vapor.Request, Swift.Error) -> Vapor.Response in static Vapor.ErrorMiddleware.default(environment: Vapor.Environment) -> Vapor.ErrorMiddleware at <compiler-generated>)) at ErrorMiddleware.swift:73:21
    frame #22: 0x0000000100152ff4 Run`protocol witness for Middleware.respond(to:chainingTo:) in conformance ErrorMiddleware at <compiler-generated>:0
    frame #23: 0x0000000100156000 Run`HTTPMiddlewareResponder.respond(request=0x00007b44000201c0, self=Vapor.HTTPMiddlewareResponder @ 0x00007b1800004f30) at Middleware.swift:43:32
    frame #24: 0x000000010015606e Run`protocol witness for Responder.respond(to:) in conformance HTTPMiddlewareResponder at <compiler-generated>:0
    frame #25: 0x000000010015672f Run`RouteLoggingMiddleware.respond(request=0x00007b44000201c0, next=Vapor.HTTPMiddlewareResponder @ 0x00007b1800004f30, self=0x00007b0800038ee0) at RouteLoggingMiddleware.swift:14:21
    frame #26: 0x0000000100156e54 Run`protocol witness for Middleware.respond(to:chainingTo:) in conformance RouteLoggingMiddleware at <compiler-generated>:0
    frame #27: 0x0000000100156000 Run`HTTPMiddlewareResponder.respond(request=0x00007b44000201c0, self=Vapor.HTTPMiddlewareResponder @ 0x00007b1800004f90) at Middleware.swift:43:32
    frame #28: 0x000000010015606e Run`protocol witness for Responder.respond(to:) in conformance HTTPMiddlewareResponder at <compiler-generated>:0
    frame #29: 0x000000010016fc2d Run`DefaultResponder.respond(request=0x00007b44000201c0, self=Vapor.DefaultResponder @ 0x00007b1000030050) at DefaultResponder.swift:67:46
    frame #30: 0x000000010017219e Run`protocol witness for Responder.respond(to:) in conformance DefaultResponder at <compiler-generated>:0
    frame #31: 0x000000010012de00 Run`HTTPServerHandler.channelRead(context=0x00007b1800010200, data=NIO.NIOAny @ 0x00007e800038b6a8, self=0x00007b2000014080) at HTTPServerHandler.swift:19:24
    frame #32: 0x000000010012fdb6 Run`protocol witness for _ChannelInboundHandler.channelRead(context:data:) in conformance HTTPServerHandler at <compiler-generated>:0
    frame #33: 0x00000001003b2baa Run`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x00007e800038b6a8, self=0x00007b1800010200) at ChannelPipeline.swift:1544:28
    frame #34: 0x00000001003b9cad Run`ChannelHandlerContext.fireChannelRead(data=NIO.NIOAny @ 0x00007e800038b6a8, self=0x00007b18000101a0) at ChannelPipeline.swift:1357:20
    frame #35: 0x00000001001434d9 Run`HTTPServerUpgradeHandler.channelRead(context=0x00007b18000101a0, data=NIO.NIOAny @ 0x00007e800038b6a8, self=0x00007b0c00059190) at HTTPServerUpgradeHandler.swift:42:17
    frame #36: 0x0000000100146526 Run`protocol witness for _ChannelInboundHandler.channelRead(context:data:) in conformance HTTPServerUpgradeHandler at <compiler-generated>:0
    frame #37: 0x00000001003b2baa Run`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x00007e800038b6a8, self=0x00007b18000101a0) at ChannelPipeline.swift:1544:28
    frame #38: 0x00000001003b9cad Run`ChannelHandlerContext.fireChannelRead(data=NIO.NIOAny @ 0x00007e800038b6a8, self=0x00007b1800010140) at ChannelPipeline.swift:1357:20
    frame #39: 0x00000001001330c3 Run`HTTPServerRequestDecoder.channelRead(context=0x00007b1800010140, data=NIO.NIOAny @ 0x00007e800038bc88, self=0x00007b1800010020) at HTTPServerRequestDecoder.swift:89:25
    frame #40: 0x0000000100139c26 Run`protocol witness for _ChannelInboundHandler.channelRead(context:data:) in conformance HTTPServerRequestDecoder at <compiler-generated>:0
    frame #41: 0x00000001003b2baa Run`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x00007e800038bc88, self=0x00007b1800010140) at ChannelPipeline.swift:1544:28
    frame #42: 0x00000001003b2c35 Run`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x00007e800038bc88, self=0x00007b18000100e0) at ChannelPipeline.swift:1546:24
    frame #43: 0x00000001003b9cad Run`ChannelHandlerContext.fireChannelRead(data=NIO.NIOAny @ 0x00007e800038bc88, self=0x00007b1800010080) at ChannelPipeline.swift:1357:20
    frame #44: 0x00000001005871f9 Run`HTTPDecoder.didFinishMessage(self=0x00007b2000014000) at HTTPDecoder.swift:583:27
    frame #45: 0x0000000100589a71 Run`protocol witness for HTTPDecoderDelegate.didFinishMessage() in conformance HTTPDecoder<A, B> at <compiler-generated>:0
    frame #46: 0x000000010057e346 Run`BetterHTTPParser.didReceiveMessageCompleteNotification(self=0x00007b440001ff40) at HTTPDecoder.swift:246:23
    frame #47: 0x000000010057be35 Run`closure #11 in BetterHTTPParser.init(opaque=0x7e800038ecd8) at HTTPDecoder.swift:125:49
    frame #48: 0x000000010057be8e Run`@objc closure #11 in BetterHTTPParser.init(kind:) at <compiler-generated>:0
    frame #49: 0x00000001005ef974 Run`c_nio_http_parser_execute(parser=0x00007e800038ecd8, settings=0x00007e800038e960, data="GET /test/async HTTP/1.1\r\nHost: localhost:8080\r\nAccept: */*\r\nAccept-Language: en-gb\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: Rested/2009 CFNetwork/1240.0.4 Darwin/20.5.0\r\n\r\n", len=201) at c_nio_http_parser.c:1926:15
    frame #50: 0x000000010058dbf6 Run`c_nio_http_parser_execute_swift(parser=0x00007e800038ecd8, settings=0x00007e800038e960, data=0x00007b7000060800, len=201) + 86
    frame #51: 0x0000000100581091 Run`closure #1 in BetterHTTPParser.feedInput(parserPtr=0x7e800038ecd8, bytes=201 values (0x7b7000060800), self=0x00007b440001ff40, parserErrno=0) at HTTPDecoder.swift:357:32
    frame #52: 0x000000010058dae3 Run`partial apply for closure #1 in BetterHTTPParser.feedInput(_:) at <compiler-generated>:0
    frame #53: 0x000000010058139c Run`thunk for @callee_guaranteed (@unowned UnsafeMutablePointer<http_parser>) -> (@unowned Int) at <compiler-generated>:0
    frame #54: 0x000000010058db3e Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafeMutablePointer<http_parser>) -> (@unowned Int) at <compiler-generated>:0
    frame #55: 0x000000010057fd63 Run`BetterHTTPParser.withExclusiveHTTPParser<T>(body=0x10058db10, self=0x00007b440001ff40) at HTTPDecoder.swift:345:16
    frame #56: 0x0000000100580255 Run`BetterHTTPParser.feedInput(bytes=201 values (0x7b7000060800), self=0x00007b440001ff40) at HTTPDecoder.swift:350:35
    frame #57: 0x00000001005887b1 Run`closure #1 in HTTPDecoder.feedInput(bytes=201 values (0x7b7000060800), self=0x00007b2000014000) at HTTPDecoder.swift:618:29
    frame #58: 0x000000010058e1e8 Run`partial apply for closure #1 in HTTPDecoder.feedInput(context:buffer:) at <compiler-generated>:0
    frame #59: 0x0000000100583d6f Run`thunk for @callee_guaranteed (@unowned UnsafeRawBufferPointer) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #60: 0x000000010058e270 Run`thunk for @callee_guaranteed (@unowned UnsafeRawBufferPointer) -> (@unowned Int, @error @owned Error)partial apply at <compiler-generated>:0
    frame #61: 0x00000001003792cc Run`ByteBuffer.withUnsafeReadableBytes<T>(body=0x10058e230, self=NIO.ByteBuffer @ 0x00007e800038f420) at ByteBuffer-core.swift:590:20
    frame #62: 0x00000001005883dc Run`HTTPDecoder.feedInput(context=0x00007b1800010080, buffer=NIO.ByteBuffer @ 0x00007e800038fdd8, self=0x00007b2000014000) at HTTPDecoder.swift:617:35
    frame #63: 0x0000000100588998 Run`HTTPDecoder.decode(context=0x00007b1800010080, buffer=NIO.ByteBuffer @ 0x00007e800038fdd8, self=0x00007b2000014000) at HTTPDecoder.swift:625:22
    frame #64: 0x00000001005894fc Run`protocol witness for ByteToMessageDecoder.decode(context:buffer:) in conformance HTTPDecoder<A, B> at <compiler-generated>:0
    frame #65: 0x00000001003e1a6e Run`closure #1 in ByteToMessageHandler.decodeLoop(decoder=0x00007b2000014000, buffer=NIO.ByteBuffer @ 0x00007e800038fdd8, decodeMode=normal, self=0x00007b2c00005800, context=0x00007b1800010080, allowEmptyBuffer=false) at Codec.swift:573:49
    frame #66: 0x00000001003ebcf1 Run`partial apply for closure #1 in ByteToMessageHandler.decodeLoop(context:decodeMode:) at <compiler-generated>:0
    frame #67: 0x00000001003dfb82 Run`ByteToMessageHandler.withNextBuffer(allowEmptyBuffer=false, body=0x1003ebcb0, self=0x00007b2c00005800) at Codec.swift:530:36
    frame #68: 0x00000001003e0e27 Run`ByteToMessageHandler.decodeLoop(context=0x00007b1800010080, decodeMode=normal, self=0x00007b2c00005800) at Codec.swift:569:35
    frame #69: 0x00000001003e370e Run`ByteToMessageHandler.channelRead(context=0x00007b1800010080, data=NIO.NIOAny @ 0x00007e8000390b88, self=0x00007b2c00005800) at Codec.swift:642:29
    frame #70: 0x00000001003e44a6 Run`protocol witness for _ChannelInboundHandler.channelRead(context:data:) in conformance ByteToMessageHandler<A> at <compiler-generated>:0
    frame #71: 0x00000001003b2baa Run`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x00007e8000390b88, self=0x00007b1800010080) at ChannelPipeline.swift:1544:28
    frame #72: 0x00000001003b2c35 Run`ChannelHandlerContext.invokeChannelRead(data=NIO.NIOAny @ 0x00007e8000390b88, self=0x00007b180000ffc0) at ChannelPipeline.swift:1546:24
    frame #73: 0x00000001003ad703 Run`ChannelPipeline.fireChannelRead0(data=NIO.NIOAny @ 0x00007e8000390b88, self=0x00007b14000123e0) at ChannelPipeline.swift:897:29
    frame #74: 0x0000000100346d01 Run`BaseStreamSocketChannel.readFromSocket(self=0x00007b4800000180) at BaseStreamSocketChannel.swift:121:35
    frame #75: 0x0000000100339e2d Run`BaseSocketChannel.readable0(self=0x00007b4800000180) at BaseSocketChannel.swift:1060:35
    frame #76: 0x000000010033bd69 Run`BaseSocketChannel.readable(self=0x00007b4800000180) at BaseSocketChannel.swift:1044:14
    frame #77: 0x000000010033da26 Run`protocol witness for SelectableChannel.readable() in conformance BaseSocketChannel<A> at <compiler-generated>:0
    frame #78: 0x00000001004c62f9 Run`SelectableEventLoop.handleEvent<C>(ev=(rawValue = 4), channel=0x00007b4800000180, self=0x00007b3c0002ffd0) at SelectableEventLoop.swift:356:25
    frame #79: 0x00000001004c844c Run`closure #2 in closure #2 in SelectableEventLoop.run(ev=NIO.SelectorEvent<NIO.NIORegistration> @ 0x00007e8000391638, self=0x00007b3c0002ffd0) at SelectableEventLoop.swift:439:30
    frame #80: 0x00000001004cf040 Run`partial apply for closure #2 in closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #81: 0x00000001004c89c5 Run`thunk for @callee_guaranteed (@guaranteed SelectorEvent<NIORegistration>) -> (@error @owned Error) at <compiler-generated>:0
    frame #82: 0x00000001004cf090 Run`partial apply for thunk for @callee_guaranteed (@guaranteed SelectorEvent<NIORegistration>) -> (@error @owned Error) at <compiler-generated>:0
    frame #83: 0x00000001004e75f9 Run`Selector.whenReady0(strategy=blockUntilTimeout, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140001ffe0) at SelectorKqueue.swift:261:17
    frame #84: 0x00000001004da518 Run`Selector.whenReady(strategy=blockUntilTimeout, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140001ffe0) at SelectorGeneric.swift:285:18
    frame #85: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c0002ffd0, nextReadyTask=0x00007b100003a280) at SelectableEventLoop.swift:431:36
    frame #86: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #87: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #88: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #89: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #90: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #91: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #92: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #93: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c0002ffd0) at SelectableEventLoop.swift:430:17
    frame #94: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c00058fe0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #95: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c00058fe0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b080002a240, _loop=0x00007b3c0002ffd0, loopUpAndRunningGroup=0x00007b1400010540) at EventLoop.swift:891:41
    frame #96: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #97: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #98: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #99: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050b80) at ThreadPosix.swift:105:13
    frame #100: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #101: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #102: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #103: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #9, name = 'NIO-ELT-0-#6'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=9, changelist=nil, nchanges=0, eventlist=0x7b7000070000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=9, changelist=nil, nchanges=0, eventlist=0x7b7000070000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b14000227e0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b14000227e0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b14000227e0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c000377d0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c000377d0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c0005a7e0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c0005a7e0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b080002a2a0, _loop=0x00007b3c000377d0, loopUpAndRunningGroup=0x00007b14000104a0) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050ac0) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #10, name = 'NIO-ELT-0-#7'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=10, changelist=nil, nchanges=0, eventlist=0x7b7000080000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=10, changelist=nil, nchanges=0, eventlist=0x7b7000080000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b1400024fe0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400024fe0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400024fe0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c0003ffc0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c0003ffc0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c0005bfe0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c0005bfe0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b0800029f80, _loop=0x00007b3c0003ffc0, loopUpAndRunningGroup=0x00007b1400010400) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050a90) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #11, name = 'NIO-ELT-0-#8'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=11, changelist=nil, nchanges=0, eventlist=0x7b7000090000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=11, changelist=nil, nchanges=0, eventlist=0x7b7000090000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b14000277e0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b14000277e0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b14000277e0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c000477c0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c000477c0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c0005d7e0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c0005d7e0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b0800029f00, _loop=0x00007b3c000477c0, loopUpAndRunningGroup=0x00007b1400010360) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050a60) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #12, name = 'NIO-ELT-0-#9'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=12, changelist=nil, nchanges=0, eventlist=0x7b70000a0000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=12, changelist=nil, nchanges=0, eventlist=0x7b70000a0000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b1400029fe0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400029fe0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b1400029fe0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c0004ffb0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c0004ffb0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c0005efe0, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c0005efe0, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b0800029da0, _loop=0x00007b3c0004ffb0, loopUpAndRunningGroup=0x00007b1400010220) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050a30) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #13, name = 'NIO-ELT-0-#10'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=13, changelist=nil, nchanges=0, eventlist=0x7b70000b0000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=13, changelist=nil, nchanges=0, eventlist=0x7b70000b0000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b140002c7e0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140002c7e0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140002c7e0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c000577b0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c000577b0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c00060000, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c00060000, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b0800029d20, _loop=0x00007b3c000577b0, loopUpAndRunningGroup=0x00007b1400010180) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050a00) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #14, name = 'NIO-ELT-0-#11'
    frame #0: 0x00007fff2047fc4a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x00000001005285d2 Run`@nonobjc kevent(_:_:_:_:_:_:) at <compiler-generated>:0
    frame #2: 0x0000000100533641 Run`closure #1 in static KQueue.kevent(kq=14, changelist=nil, nchanges=0, eventlist=0x7b70000c0000, nevents=64, timeout=nil) at System.swift:608:13
    frame #3: 0x00000001005350ee Run`partial apply for closure #1 in static KQueue.kevent(kq:changelist:nchanges:eventlist:nevents:timeout:) at <compiler-generated>:0
    frame #4: 0x000000010052ab3c Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error) at <compiler-generated>:0
    frame #5: 0x0000000100535150 Run`thunk for @callee_guaranteed () -> (@unowned Int32, @error @owned Error)partial apply at <compiler-generated>:0
    frame #6: 0x0000000100528f51 Run`syscall<T>(blocking=false, function="kevent(kq:changelist:nchanges:eventlist:nevents:timeout:)", body=0x100535120) at System.swift:157:23
    frame #7: 0x000000010053340d Run`static KQueue.kevent(kq=14, changelist=nil, nchanges=0, eventlist=0x7b70000c0000, nevents=64, timeout=nil, self=NIO.KQueue) at System.swift:607:20
    frame #8: 0x00000001004e816a Run`closure #1 in Selector.whenReady0(ts=nil, self=0x00007b140002efe0) at SelectorKqueue.swift:215:28
    frame #9: 0x00000001004e9310 Run`partial apply for closure #1 in Selector.whenReady0(strategy:onLoopBegin:_:) at <compiler-generated>:0
    frame #10: 0x00000001004e82c4 Run`thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #11: 0x00000001004e9388 Run`partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<timespec>?) -> (@unowned Int, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x00000001004cfe00 Run`Optional.withUnsafeOptionalPointer<Wrapped>(body=0x1004e9350, self=nil) at SelectorGeneric.swift:30:24
    frame #13: 0x00000001004e5954 Run`Selector.whenReady0(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140002efe0) at SelectorKqueue.swift:214:34
    frame #14: 0x00000001004da518 Run`Selector.whenReady(strategy=block, loopStart=0x00000001004cef90, body=0x1004cf060, self=0x00007b140002efe0) at SelectorGeneric.swift:285:18
    frame #15: 0x00000001004c7f6d Run`closure #2 in SelectableEventLoop.run(self=0x00007b3c0005ffa0, nextReadyTask=nil) at SelectableEventLoop.swift:431:36
    frame #16: 0x00000001004cd4b8 Run`partial apply for closure #2 in SelectableEventLoop.run() at <compiler-generated>:0
    frame #17: 0x00000001003256d8 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #18: 0x00000001004cd520 Run`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
    frame #19: 0x00000001004c04f4 Run`closure #1 in withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:23:13
    frame #20: 0x00000001004c0598 Run`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
    frame #21: 0x00007fff33623dae libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<τ_0_0>(invoking: () throws -> τ_0_0) throws -> τ_0_0 + 46
    frame #22: 0x00000001004c0416 Run`withAutoReleasePool<T>(execute=0x1004cd4f0) at SelectableEventLoop.swift:22:16
    frame #23: 0x00000001004c6881 Run`SelectableEventLoop.run(self=0x00007b3c0005ffa0) at SelectableEventLoop.swift:430:17
    frame #24: 0x000000010041980d Run`static MultiThreadedEventLoopGroup.runTheLoop(thread=0x00007b0c00061800, canEventLoopBeShutdownIndividually=false, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, callback=0x0000000100424800, self=NIO.MultiThreadedEventLoopGroup) at EventLoop.swift:871:22
    frame #25: 0x000000010041a2f0 Run`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=0x00007b0c00061800, selectorFactory=0x000000010041a7e0, initializer=0x0000000100424570, lock=0x00007b0800029ca0, _loop=0x00007b3c0005ffa0, loopUpAndRunningGroup=0x00007b14000100e0) at EventLoop.swift:891:41
    frame #26: 0x00000001004246b5 Run`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:selectorFactory:initializer:) at <compiler-generated>:0
    frame #27: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #28: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #29: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c000509d0) at ThreadPosix.swift:105:13
    frame #30: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #31: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #32: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #33: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
  thread #15, name = 'TP-#0'
    frame #0: 0x00007fff2047b2f6 libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x000000010321a85c libdispatch.dylib`_dispatch_sema4_wait + 16
    frame #2: 0x000000010321ad2e libdispatch.dylib`_dispatch_semaphore_wait_slow + 98
    frame #3: 0x0000000102505059 libclang_rt.tsan_osx_dynamic.dylib`wrap_dispatch_semaphore_wait + 137
    frame #4: 0x0000000100483a9b Run`NIOThreadPool.process(identifier=0, self=0x00007b14000102c0) at NIOThreadPool.swift:139:28
    frame #5: 0x0000000100485b98 Run`closure #3 in NIOThreadPool.start(thread=0x00007b0c00063000, self=0x00007b14000102c0, group=0x00007b140000fff0, id=0) at NIOThreadPool.swift:196:22
    frame #6: 0x000000010048740a Run`partial apply for closure #3 in NIOThreadPool.start() at <compiler-generated>:0
    frame #7: 0x000000010041ab14 Run`thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #8: 0x000000010053588e Run`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () at <compiler-generated>:0
    frame #9: 0x000000010053d4c8 Run`closure #1 in static ThreadOpsPosix.run($0=0x7b0c00050940) at ThreadPosix.swift:105:13
    frame #10: 0x000000010053d69e Run`@objc closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) at <compiler-generated>:0
    frame #11: 0x00000001024bca2d libclang_rt.tsan_osx_dynamic.dylib`__tsan_thread_start_func + 141
    frame #12: 0x00000001032c01b8 libsystem_pthread.dylib`_pthread_start + 224
    frame #13: 0x00000001032bbaf7 libsystem_pthread.dylib`thread_start + 15
(lldb) 
Lukasa commented 3 years ago

This crash seems to be in the Swift runtime itself. I can see from the backtraces that you are already running under TSAN, so I assume this crash is not the result of a thread-safety issue. In that case, I suspect the issue is in the Swift runtime itself.

Can you produce a smaller reproducer scenario?

0xTim commented 3 years ago

@Lukasa I've updated with a small repro

PeterAdams-A commented 3 years ago

Just to add a data point to this which probably will not comfort you much - your example works for me.

We appear to have the same swift (which I was surprised by).

Lukasa commented 3 years ago

@0xTim What OS and Xcode is this reproducing with?

0xTim commented 3 years ago

@Lukasa macOS 11.4 and Xcode 13 Beta 1. Just tested on macOS 12 and it works for me too on there

Lukasa commented 3 years ago

Concurrency features don't work on macOS 11.4, so I'm not surprised this doesn't work there. Closing because this is a Swift issue.

mxcl commented 3 years ago

Just as an FYI, I am on macOS 12 with Xcode 13 beta 2 and a similar crash is now happening in this function for a Vapor project using async/await. It worked with beta 1.

Currently trying to diagnose it.

Lukasa commented 3 years ago

Did you get anywhere with this?

0xTim commented 3 years ago

@Lukasa this is crashing on macOS 12.0 Beta and Xcode 13 Beta 2. Here are the updated details, reproduction steps are the same:

SwiftNIO version/commit hash

2.30.0

Swift & OS version (output of swift --version && uname -a)

swift-driver version: 1.26 Apple Swift version 5.5 (swiftlang-1300.0.20.104 clang-1300.0.21.1)
Target: x86_64-apple-macosx12.0
Darwin Tims-MBP-2018.brokenhands.net 21.0.0 Darwin Kernel Version 21.0.0: Thu May 27 21:01:58 PDT 2021; root:xnu-7938.0.0.111.2~2/RELEASE_X86_64 x86_64

Stacktrace

(lldb) bt all
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8)
    frame #0: 0x000000010018d0ba AsyncCrashSmall`EventLoopPromise.completeWithAsync(body=0x10019bcd0, self=NIO.EventLoopPromise<Swift.String> @ 0x00000001045ab198) at AsyncAwaitSupport.swift:0
  * frame #1: 0x0000000100004a78 AsyncCrashSmall`makeString() at main.swift:7:13
    frame #2: 0x0000000100004847 AsyncCrashSmall`main at main.swift:17:20
    frame #3: 0x00000001005094d5 dyld`start + 421
Lukasa commented 3 years ago

Thanks @0xTim, I'll try to put together a repro on my end.

0xTim commented 3 years ago

Is it worth reopening this?

Lukasa commented 3 years ago

Yup.

0xTim commented 3 years ago

This appears to work in Monterey Beta 2

mxcl commented 3 years ago

Yeah confirmed, was just a rev lock issue. Should have occurred to me, apologies.

maartene commented 3 years ago

So, can I conclude that this is a macOS 11.4 issue and that this works fine in macOS 12?

I'm asking because I'm working on a project that worked fine with Xcode 13 beta 1 on macOS 11.4, but this crash now happens after upgrading to beta 3. I see the crash happening both in my own project as well as the example 0xTim provided in the original post.

Versions in use:

If the crash was introduced somewhere between beta 1 and 3, is this really a Monterey issue?

(I only have one Mac, and can't afford to install beta OS on this so I can't confirm myself. Wish Apple would provide some form of virtualization feature to test the beta OS)

Lukasa commented 3 years ago

Are you sure you’re getting a crash in completeWithAsync?

None of the async features will run on macOS 11. They should be hidden behind an availability guard that makes them literally unreachable on your platform.

maartene commented 3 years ago

Yeah, the availability guard gets ignored by this flag in Package.swift:

.unsafeFlags([
                    "-Xfrontend", "-disable-availability-checking",

Anyway, I found the issue: Xcode-beta 3 reverted to its built in tool chain. After downloading and choosing the latest toolchain for Swift 5.5 from swift.org, it works again.

rkreutz commented 2 years ago

Hey there, I actually got this same crash recently, I'm running Xcode 13.2.1 on macOS 11.6.8, unfortunately I cannot update to Xcode 13.3 or anything above because I do not have Monterey installed, and I can't install Monterey because my MBP is from mid-2014. However, I have managed to get around the crash by installing the latest toolchain from swift.org (Swift 5.6.3 Release at the time). Since the old discussion was around betas I thought it would be worth sharing this in case others have the same issue as I had recently. Thanks