Open
Description
This was caught while trying to debugging this issue. hummingbird-project/swift-jobs-postgres#14.
My test case would access a Postgres a couple of times every 2 or 3 minutes. After about 10 hours my test would crash on this line
This is the call stack
Callstack
_swift_runtime_on_report (@_swift_runtime_on_report:3)
_swift_stdlib_reportFatalErrorInFile (@_swift_stdlib_reportFatalErrorInFile:55)
closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never (@closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never:29)
Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never (@Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never:149)
_ConnectionPoolModule.PoolStateMachine.connectionIdleTimerTriggered(τ_0_2) -> _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5>.Action (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/PoolStateMachine.swift:390)
_ConnectionPoolModule.PoolStateMachine.timerTriggered(_ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5>.Timer) -> _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5>.Action (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/PoolStateMachine.swift:313)
closure #3 (inout _ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.State) -> _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Action in closure #1 (inout Swift.TaskGroup<_ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.TimerRunResult>) async -> () in closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> () (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/ConnectionPool.swift:539)
partial apply forwarder for closure #3 (inout _ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.State) -> _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Action in closure #1 (inout Swift.TaskGroup<_ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.TimerRunResult>) async -> () in closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> () (@partial apply forwarder for closure #3 (inout _ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.State) -> _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Action in closure #1 (inout Swift.TaskGroup<_ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.TimerRunResult>) async -> () in closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> ():44)
closure #1 (Swift.UnsafeMutablePointer<τ_0_0>, Swift.UnsafeMutablePointer<__C._opaque_pthread_mutex_t>) throws -> τ_1_0 in _ConnectionPoolModule.LockStorage.withLockedValue<τ_0_0>((inout τ_0_0) throws -> τ_1_0) throws -> τ_1_0 (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/NIOLock.swift:186)
partial apply forwarder for closure #1 (Swift.UnsafeMutablePointer<τ_0_0>, Swift.UnsafeMutablePointer<__C._opaque_pthread_mutex_t>) throws -> τ_1_0 in _ConnectionPoolModule.LockStorage.withLockedValue<τ_0_0>((inout τ_0_0) throws -> τ_1_0) throws -> τ_1_0 (@partial apply forwarder for closure #1 (Swift.UnsafeMutablePointer<τ_0_0>, Swift.UnsafeMutablePointer<__C._opaque_pthread_mutex_t>) throws -> τ_1_0 in _ConnectionPoolModule.LockStorage.withLockedValue<τ_0_0>((inout τ_0_0) throws -> τ_1_0) throws -> τ_1_0:16)
Swift.ManagedBuffer< where τ_0_1: ~Swift.Copyable>.withUnsafeMutablePointers<τ_0_0, τ_0_1 where τ_1_0: Swift.Error, τ_1_1: ~Swift.Copyable>((Swift.UnsafeMutablePointer<τ_0_0>, Swift.UnsafeMutablePointer<τ_0_1>) throws(τ_1_0) -> τ_1_1) throws(τ_1_0) -> τ_1_1 (@Swift.ManagedBuffer< where τ_0_1: ~Swift.Copyable>.withUnsafeMutablePointers<τ_0_0, τ_0_1 where τ_1_0: Swift.Error, τ_1_1: ~Swift.Copyable>((Swift.UnsafeMutablePointer<τ_0_0>, Swift.UnsafeMutablePointer<τ_0_1>) throws(τ_1_0) -> τ_1_1) throws(τ_1_0) -> τ_1_1:46)
_ConnectionPoolModule.LockStorage.withLockedValue<τ_0_0>((inout τ_0_0) throws -> τ_1_0) throws -> τ_1_0 (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/NIOLock.swift:183)
_ConnectionPoolModule.NIOLockedValueBox.withLockedValue<τ_0_0>((inout τ_0_0) throws -> τ_1_0) throws -> τ_1_0 (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/NIOLockedValueBox.swift:42)
(3) suspend resume partial function for closure #1 (inout Swift.TaskGroup<_ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.TimerRunResult>) async -> () in closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> () (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/ConnectionPool.swift:538)
(1) await resume partial function for partial apply forwarder for closure #1 (inout Swift.TaskGroup<_ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.TimerRunResult>) async -> () in closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> () (@(1) await resume partial function for partial apply forwarder for closure #1 (inout Swift.TaskGroup<_ConnectionPoolModule.ConnectionPool<τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7>.TimerRunResult>) async -> () in closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> ():3)
(2) await resume partial function for Swift.withTaskGroup<τ_0_0, τ_0_1 where τ_0_0: Swift.Sendable>(of: τ_0_0.Type, returning: τ_0_1.Type, isolation: isolated Swift.Optional<Swift.Actor>, body: (inout Swift.TaskGroup<τ_0_0>) async -> τ_0_1) async -> τ_0_1 (@(2) await resume partial function for Swift.withTaskGroup<τ_0_0, τ_0_1 where τ_0_0: Swift.Sendable>(of: τ_0_0.Type, returning: τ_0_1.Type, isolation: isolated Swift.Optional<Swift.Actor>, body: (inout Swift.TaskGroup<τ_0_0>) async -> τ_0_1) async -> τ_0_1:3)
(2) await resume partial function for back deployment thunk for Swift.withTaskGroup<τ_0_0, τ_0_1 where τ_0_0: Swift.Sendable>(of: τ_0_0.Type, returning: τ_0_1.Type, isolation: isolated Swift.Optional<Swift.Actor>, body: (inout Swift.TaskGroup<τ_0_0>) async -> τ_0_1) async -> τ_0_1 (@(2) await resume partial function for back deployment thunk for Swift.withTaskGroup<τ_0_0, τ_0_1 where τ_0_0: Swift.Sendable>(of: τ_0_0.Type, returning: τ_0_1.Type, isolation: isolated Swift.Optional<Swift.Actor>, body: (inout Swift.TaskGroup<τ_0_0>) async -> τ_0_1) async -> τ_0_1:3)
(2) await resume partial function for closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> () (/Users/adamfowler/Developer/server/hummingbird-project/swift-jobs-tests/.build/checkouts/postgres-nio/Sources/ConnectionPoolModule/ConnectionPool.swift:507)
(1) await resume partial function for partial apply forwarder for closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> () (@(1) await resume partial function for partial apply forwarder for closure #1 @Sendable () async -> () in _ConnectionPoolModule.ConnectionPool.runTimer<τ_0_0 where τ_1_0: _ConnectionPoolModule.TaskGroupProtocol>(_: _ConnectionPoolModule.PoolStateMachine<τ_0_0, τ_0_2, τ_0_1, τ_0_3, τ_0_4, Swift.CheckedContinuation<(), Swift.Never>>.Timer, in: inout τ_1_0) -> ():3)
(1) await resume partial function for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> () to @escaping @isolated(any) @callee_guaranteed @async () -> () (@(1) await resume partial function for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> () to @escaping @isolated(any) @callee_guaranteed @async () -> ():3)
(1) await resume partial function for partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> () to @escaping @isolated(any) @callee_guaranteed @async () -> () (@(1) await resume partial function for partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> () to @escaping @isolated(any) @callee_guaranteed @async () -> ():3)
(1) await resume partial function for reabstraction thunk helper from @escaping @isolated(any) @callee_guaranteed @async () -> () to @escaping @callee_guaranteed @async () -> (@error @owned Swift.Error) (@(1) await resume partial function for reabstraction thunk helper from @escaping @isolated(any) @callee_guaranteed @async () -> () to @escaping @callee_guaranteed @async () -> (@error @owned Swift.Error):3)
(1) await resume partial function for partial apply forwarder for reabstraction thunk helper from @escaping @isolated(any) @callee_guaranteed @async () -> () to @escaping @callee_guaranteed @async () -> (@error @owned Swift.Error) (@(1) await resume partial function for partial apply forwarder for reabstraction thunk helper from @escaping @isolated(any) @callee_guaranteed @async () -> () to @escaping @callee_guaranteed @async () -> (@error @owned Swift.Error):3)