I'm having a really frustrating time debugging my Vapor app in Xcode. If I turn on the "Swift error" breakpoint in Xcode, and then debug my app, I get constant breaks in NIO.System.wrapSyscall(…)
, which makes it almost impossible to meaningfully debug what is actually going wrong in my app. Here's a backtrace that occurs immediately after starting a test run:
Backtrace
* thread #5, name = 'NIO-ELT-#0', stop reason = breakpoint 3.1
frame #0: 0x00007fff65bedf30 libswiftCore.dylib`swift_willThrow
* frame #1: 0x0000000111f05a21 AppTests`wrapSyscall<T>(function="getpeername(socket:address:addressLength:)", body=0x0000000111f0b400 AppTests`reabstraction thunk helper from @callee_guaranteed () -> (@unowned Swift.Int32, @error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out Swift.Int32, @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".19" at <compiler-generated>) at System.swift:145:13
frame #2: 0x0000000111f0b33c AppTests`static Posix.getpeername(socket=9, address=0x00007000019a4ba0, addressLength=0x00007000019a4808, self=NIO.Posix) at System.swift:466:13
frame #3: 0x0000000111de7f41 AppTests`closure #1 in BaseSocket.remoteAddress($0=9, $1=0x00007000019a4ba0, $2=0x00007000019a4808) at BaseSocket.swift:234:41
frame #4: 0x0000000111de8583 AppTests`closure #1 in closure #1 in BaseSocket.get_addr(fd=9, body=0x0000000111de7f10 AppTests`closure #1 (Swift.Int32, Swift.UnsafeMutablePointer<__C.sockaddr>, Swift.UnsafeMutablePointer<Swift.UInt32>) throws -> () in NIO.BaseSocket.remoteAddress() throws -> NIO.SocketAddress at BaseSocket.swift:234, addressPtr=0x00007000019a4ba0, size=128) at BaseSocket.swift:245:21
frame #5: 0x0000000111dec3bc AppTests`partial apply for closure #1 in closure #1 in BaseSocket.get_addr(_:) at <compiler-generated>:0
frame #6: 0x0000000111de85cf AppTests`thunk for @callee_guaranteed (@unowned Int32) -> (@error @owned Error) at <compiler-generated>:0
frame #7: 0x0000000111dec3e4 AppTests`thunk for @callee_guaranteed (@unowned Int32) -> (@error @owned Error)partial apply at <compiler-generated>:0
frame #8: 0x0000000111de7c7f AppTests`BaseSocket.withUnsafeFileDescriptor<T>(body=0x0000000111dec3d0 AppTests`reabstraction thunk helper from @callee_guaranteed (@unowned Swift.Int32) -> (@error @owned Swift.Error) to @escaping @callee_guaranteed (@unowned Swift.Int32) -> (@out (), @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".8" at <compiler-generated>, self=(descriptor = 9)) at BaseSocket.swift:218:20
frame #9: 0x0000000111de84da AppTests`closure #1 in BaseSocket.get_addr(addressPtr=0x00007000019a4ba0, size=128, self=(descriptor = 9), body=0x0000000111de7f10 AppTests`closure #1 (Swift.Int32, Swift.UnsafeMutablePointer<__C.sockaddr>, Swift.UnsafeMutablePointer<Swift.UInt32>) throws -> () in NIO.BaseSocket.remoteAddress() throws -> NIO.SocketAddress at BaseSocket.swift:234) at BaseSocket.swift:244:17
frame #10: 0x0000000111dec378 AppTests`partial apply for closure #1 in BaseSocket.get_addr(_:) at <compiler-generated>:0
frame #11: 0x0000000111de862f AppTests`thunk for @callee_guaranteed (@unowned UnsafeMutablePointer<sockaddr>, @unowned Int) -> (@error @owned Error) at <compiler-generated>:0
frame #12: 0x0000000111dec394 AppTests`partial apply for thunk for @callee_guaranteed (@unowned UnsafeMutablePointer<sockaddr>, @unowned Int) -> (@error @owned Error) at <compiler-generated>:0
frame #13: 0x0000000111de4df5 AppTests`closure #1 in sockaddr_storage.withMutableSockAddr<R>(p=Swift.UnsafeMutableRawBufferPointer @ 0x00007000019a49a0, body=0x0000000111dec380 AppTests`partial apply forwarder for reabstraction thunk helper from @callee_guaranteed (@unowned Swift.UnsafeMutablePointer<__C.sockaddr>, @unowned Swift.Int) -> (@error @owned Swift.Error) to @escaping @callee_guaranteed (@unowned Swift.UnsafeMutablePointer<__C.sockaddr>, @unowned Swift.Int) -> (@out (), @error @owned Swift.Error) at <compiler-generated>) at BaseSocket.swift:137:17
frame #14: 0x0000000111de4e7a AppTests`partial apply for closure #1 in sockaddr_storage.withMutableSockAddr<A>(_:) at <compiler-generated>:0
frame #15: 0x00007fff6596af10 libswiftCore.dylib`merged Swift.withUnsafeMutableBytes<A, B>(of: inout A, _: (Swift.UnsafeMutableRawBufferPointer) throws -> B) throws -> B + 32
frame #16: 0x00007fff6596aeac libswiftCore.dylib`Swift.withUnsafeMutableBytes<A, B>(of: inout A, _: (Swift.UnsafeMutableRawBufferPointer) throws -> B) throws -> B + 28
frame #17: 0x0000000111de4c31 AppTests`sockaddr_storage.withMutableSockAddr<R>(body=0x0000000111dec380 AppTests`partial apply forwarder for reabstraction thunk helper from @callee_guaranteed (@unowned Swift.UnsafeMutablePointer<__C.sockaddr>, @unowned Swift.Int) -> (@error @owned Swift.Error) to @escaping @callee_guaranteed (@unowned Swift.UnsafeMutablePointer<__C.sockaddr>, @unowned Swift.Int) -> (@out (), @error @owned Swift.Error) at <compiler-generated>, self=Darwin.sockaddr_storage @ 0x00007000019a4ba0) at BaseSocket.swift:136:20
frame #18: 0x0000000111de82da AppTests`BaseSocket.get_addr(body=0x0000000111de7f10 AppTests`closure #1 (Swift.Int32, Swift.UnsafeMutablePointer<__C.sockaddr>, Swift.UnsafeMutablePointer<Swift.UInt32>) throws -> () in NIO.BaseSocket.remoteAddress() throws -> NIO.SocketAddress at BaseSocket.swift:234, self=(descriptor = 9)) at BaseSocket.swift:241:18
frame #19: 0x0000000111de7ec4 AppTests`BaseSocket.remoteAddress(self=(descriptor = 9)) at BaseSocket.swift:234:20
frame #20: 0x0000000111df23b5 AppTests`BaseSocketChannel.init(socket=<no summary available>, parent=nil, eventLoop=0x0000000100bdff90, recvAllocator=NIO.AdaptiveRecvByteBufferAllocator @ 0x0000000100cb8bb0, self=<no summary available>) at BaseSocketChannel.swift:397:96
frame #21: 0x0000000111ef065c AppTests`SocketChannel.init(eventLoop=0x0000000100bdff90, protocolFamily=30) at SocketChannel.swift:59:19
frame #22: 0x0000000111ef021d AppTests`SocketChannel.__allocating_init(eventLoop:protocolFamily:) at SocketChannel.swift:0
frame #23: 0x0000000111e0f6ea AppTests`ClientBootstrap.execute(eventLoop=(instance = 0x0000000100bdff90 -> 0x0000000112613c90 type metadata for NIO.SelectableEventLoop, witness_table_EventLoop = 0x00000001125d46d8 AppTests`protocol witness table for NIO.SelectableEventLoop : NIO.EventLoop in NIO), protocolFamily=30, body=0x0000000111e0f130 AppTests`closure #1 (NIO.Channel) -> NIO.EventLoopFuture<()> in closure #1 (NIO.EventLoop, Swift.Int32) -> NIO.EventLoopFuture<NIO.Channel> in NIO.ClientBootstrap.connect(host: Swift.String, port: Swift.Int) -> NIO.EventLoopFuture<NIO.Channel> at Bootstrap.swift:424, self=0x00000001065f9b50) at Bootstrap.swift:502:27
frame #24: 0x0000000111e0f119 AppTests`closure #1 in ClientBootstrap.connect(eventLoop=(instance = 0x0000000100bdff90 -> 0x0000000112613c90 type metadata for NIO.SelectableEventLoop, witness_table_EventLoop = 0x00000001125d46d8 AppTests`protocol witness table for NIO.SelectableEventLoop : NIO.EventLoop in NIO), protocolFamily=30, self=0x00000001065f9b50) at Bootstrap.swift:424:25
frame #25: 0x0000000111e9543d AppTests`HappyEyeballsConnector.connectToTarget(target=v6, self=0x00000001065f9f40) at HappyEyeballs.swift:529:29
frame #26: 0x0000000111e94a69 AppTests`HappyEyeballsConnector.beginConnecting(self=0x00000001065f9f40) at HappyEyeballs.swift:459:9
frame #27: 0x0000000111e93ab4 AppTests`HappyEyeballsConnector.processInput(input=resolverAAAACompleted, self=0x00000001065f9f40) at HappyEyeballs.swift:331:13
frame #28: 0x0000000111e978cd AppTests`closure #3 in HappyEyeballsConnector.whenAAAALookupComplete(self=0x00000001065f9f40) at HappyEyeballs.swift:629:18
frame #29: 0x0000000111e82737 AppTests`closure #1 in EventLoopFuture.whenComplete(callback=0x0000000111e99690 AppTests`partial apply forwarder for closure #3 () -> () in NIO.HappyEyeballsConnector.(whenAAAALookupComplete in _2EDDDA16464B5E6B93684A67F9A71C90)(future: NIO.EventLoopFuture<Swift.Array<NIO.SocketAddress>>) -> () at <compiler-generated>) at EventLoopFuture.swift:667:13
frame #30: 0x0000000111e7fcb2 AppTests`EventLoopFuture._addCallback(callback=0x0000000111e849e0 AppTests`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.whenComplete(() -> ()) -> () at <compiler-generated>, self=0x0000000100cb82c0) at EventLoopFuture.swift:597:16
frame #31: 0x0000000111e7fea2 AppTests`EventLoopFuture._whenComplete(callback=0x0000000111e849e0 AppTests`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.whenComplete(() -> ()) -> () at <compiler-generated>, self=0x0000000100cb82c0) at EventLoopFuture.swift:603:13
frame #32: 0x0000000111e826e6 AppTests`EventLoopFuture.whenComplete(callback=0x0000000111e99690 AppTests`partial apply forwarder for closure #3 () -> () in NIO.HappyEyeballsConnector.(whenAAAALookupComplete in _2EDDDA16464B5E6B93684A67F9A71C90)(future: NIO.EventLoopFuture<Swift.Array<NIO.SocketAddress>>) -> () at <compiler-generated>, self=0x0000000100cb82c0) at EventLoopFuture.swift:666:9
frame #33: 0x0000000111e97540 AppTests`HappyEyeballsConnector.whenAAAALookupComplete(future=0x00000001065f9ef0, self=0x00000001065f9f40) at HappyEyeballs.swift:621:11
frame #34: 0x0000000111e943b1 AppTests`HappyEyeballsConnector.beginDNSResolution(self=0x00000001065f9f40) at HappyEyeballs.swift:431:9
frame #35: 0x0000000111e939d0 AppTests`HappyEyeballsConnector.processInput(input=resolve, self=0x00000001065f9f40) at HappyEyeballs.swift:322:13
frame #36: 0x0000000111e93857 AppTests`closure #1 in HappyEyeballsConnector.resolveAndConnect(self=0x00000001065f9f40) at HappyEyeballs.swift:308:18
frame #37: 0x0000000111e71dec AppTests`thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0
frame #38: 0x0000000111e7a4e1 AppTests`partial apply for thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0
frame #39: 0x0000000111e71e0c AppTests`thunk for @escaping @callee_guaranteed () -> (@out ()) at <compiler-generated>:0
frame #40: 0x0000000111e71e57 AppTests`closure #3 in SelectableEventLoop.run(task=0x0000000111e77880 AppTests`partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed () -> (@out ()) to @escaping @callee_guaranteed () -> () at <compiler-generated>) at EventLoop.swift:726:25
frame #41: 0x0000000111df422f AppTests`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
frame #42: 0x0000000111e77844 AppTests`thunk for @callee_guaranteed () -> (@error @owned Error)partial apply at <compiler-generated>:0
frame #43: 0x0000000111e6d4f2 AppTests`closure #1 in withAutoReleasePool<T>(execute=0x0000000111e77830 AppTests`reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".20" at <compiler-generated>) at EventLoop.swift:451:13
frame #44: 0x0000000111e7a50f AppTests`partial apply for closure #1 in withAutoReleasePool<A>(_:) at <compiler-generated>:0
frame #45: 0x00007fff66118f0e libswiftObjectiveC.dylib`ObjectiveC.autoreleasepool<A>(invoking: () throws -> A) throws -> A + 46
frame #46: 0x0000000111e6d499 AppTests`withAutoReleasePool<T>(execute=0x0000000111e77830 AppTests`reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".20" at <compiler-generated>) at EventLoop.swift:450:16
frame #47: 0x0000000111e70ddb AppTests`SelectableEventLoop.run(self=0x0000000100bdff90) at EventLoop.swift:725:21
frame #48: 0x0000000111e7421c AppTests`closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(t=(pthread = 0x00007000019a7000), initializer=0x0000000111e79f80 AppTests`partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@in_guaranteed NIO.Thread) -> (@out ()) to @escaping @callee_guaranteed (@guaranteed NIO.Thread) -> () at <compiler-generated>, self=0x0000000112613da0, lock=(mutex = 0x00000001065d6050), _loop=0x0000000100bdff90, loopUpAndRunningGroup=0x00000001065d6090) at EventLoop.swift:892:23
frame #49: 0x0000000111e7a05a AppTests`partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) at <compiler-generated>:0
frame #50: 0x0000000111e747cf AppTests`thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () at <compiler-generated>:0
frame #51: 0x0000000111f0d871 AppTests`partial apply for thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () at <compiler-generated>:0
frame #52: 0x0000000111f0dc2b AppTests`closure #1 in static Thread.spawnAndRun(p=(_rawValue = 0x00000001065ef250)) at Thread.swift:104:13
frame #53: 0x0000000111f0dca9 AppTests`@objc closure #1 in static Thread.spawnAndRun(name:body:) at <compiler-generated>:0
frame #54: 0x00007fff66672d76 libsystem_pthread.dylib`_pthread_start + 125
frame #55: 0x00007fff6666f5d3 libsystem_pthread.dylib`thread_start + 15
To be clear, this happens even when I run an otherwise fully-functional app with that breakpoint enabled. I brought this up in Discord late last week, and the response was essentially "don't use the Swift error breakpoint". That's not really realistic.
Are there any workarounds or fixes? Where should I be reporting this as a problem?