Crash while receiving response
ccmwa opened this issue ยท 8 comments
AsyncHTTPClient crashes (unwrapping nil value) while receiving an HTTP response :
Received signal 4. Backtrace:
0x55b95e5da9c2, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /build/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
0x7fc3469ec3bf
0x55b95e4b802a, Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag+StateMachine.swift:0
0x55b95e4b802a, generic specialization <NIOCore.ByteBuffer> of NIOCore.CircularBuffer.removeFirst() -> A at /build/<compiler-generated>:0
0x55b95e4b802a, AsyncHTTPClient.RequestBag.StateMachine.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> Swift.Optional<NIOCore.ByteBuffer> at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag+StateMachine.swift:314
0x55b95e4bf004, AsyncHTTPClient.RequestBag.(receiveResponseBodyParts0 in _828EC98A744D86D088B343098CA6B2A6)(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag.swift:214
0x55b95e4c22b9, closure #1 () -> () in AsyncHTTPClient.RequestBag.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag.swift:422
0x55b95e4c22b9, partial apply forwarder for closure #1 () -> () in AsyncHTTPClient.RequestBag.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/<compiler-generated>:0
0x55b95ec75f9b, reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /build/<compiler-generated>:0
0x55b95ec75f9b, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /build/<compiler-generated>:0
0x55b95ec6f7f0, reabstraction thunk helper from @escaping @callee_guaranteed () -> (@out ()) to @escaping @callee_guaranteed () -> () at /build/<compiler-generated>:0
0x55b95ec6f7f0, closure #4 () -> () in NIOPosix.SelectableEventLoop.run() throws -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:520
0x55b95ec6f7f0, reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error) at /build/<compiler-generated>:0
0x55b95ec6f7f0, generic specialization <()> of NIOPosix.withAutoReleasePool<A>(() throws -> A) throws -> A at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:28
0x55b95ec6f7f0, NIOPosix.SelectableEventLoop.run() throws -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:519
0x55b95ec5ada4, static NIOPosix.MultiThreadedEventLoopGroup.(runTheLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(thread: NIOPosix.NIOThread, parentGroup: Swift.Optional<NIOPosix.MultiThreadedEventLoopGroup>, canEventLoopBeShutdownIndividually: Swift.Bool, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> (), _: (NIOPosix.SelectableEventLoop) -> ()) -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:89
0x55b95ec5ada4, closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, parentGroup: NIOPosix.MultiThreadedEventLoopGroup, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /build/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:110
0x55b95ec5d8ee, partial apply forwarder for closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, parentGroup: NIOPosix.MultiThreadedEventLoopGroup, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /build/<compiler-generated>:0
0x55b95ec5dbe9, reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /build/<compiler-generated>:0
0x55b95ec5d90d, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /build/<compiler-generated>:0
0x55b95ec8a295, closure #1 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in static NIOPosix.ThreadOpsPosix.run(handle: inout Swift.Optional<Swift.UInt>, args: NIOPosix.Box<(body: (NIOPosix.NIOThread) -> (), name: Swift.Optional<Swift.String>)>, detachThread: Swift.Bool) -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:105
0x7fc3469e0608
0x7fc345e53292
0xffffffffffffffff
I'm using version 1.9.0 (7a4dfe026f6ee0f8ad741b58df74c60af296365d
).
Is there any update on this?
my app just crashed with this log
[ NOTICE ] Server starting on http://0.0.0.0:8080
Received signal 4. Backtrace:
0x55e66c16eb52, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /build/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
0x7fc6fc3fb3bf
0x55e66c049f2a, Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag+StateMachine.swift:0
0x55e66c049f2a, generic specialization <NIOCore.ByteBuffer> of NIOCore.CircularBuffer.removeFirst() -> A at /build/<compiler-generated>:0
0x55e66c049f2a, AsyncHTTPClient.RequestBag.StateMachine.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> Swift.Optional<NIOCore.ByteBuffer> at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag+StateMachine.swift:311
0x55e66c0513d4, AsyncHTTPClient.RequestBag.(receiveResponseBodyParts0 in _828EC98A744D86D088B343098CA6B2A6)(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag.swift:215
0x55e66c054839, closure #1 () -> () in AsyncHTTPClient.RequestBag.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag.swift:423
0x55e66c054839, partial apply forwarder for closure #1 () -> () in AsyncHTTPClient.RequestBag.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/<compiler-generated>:0
0x55e66c6d90ab, reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /build/<compiler-generated>:0
0x55e66c6d90ab, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /build/<compiler-generated>:0
0x55e66c6d42a0, reabstraction thunk helper from @escaping @callee_guaranteed () -> (@out ()) to @escaping @callee_guaranteed () -> () at /build/<compiler-generated>:0
0x55e66c6d42a0, closure #4 () -> () in NIOPosix.SelectableEventLoop.run() throws -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:509
0x55e66c6d42a0, reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error) at /build/<compiler-generated>:0
0x55e66c6d42a0, generic specialization <()> of NIOPosix.withAutoReleasePool<A>(() throws -> A) throws -> A at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:28
0x55e66c6d42a0, NIOPosix.SelectableEventLoop.run() throws -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:508
0x55e66c6bf257, static NIOPosix.MultiThreadedEventLoopGroup.(runTheLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(thread: NIOPosix.NIOThread, canEventLoopBeShutdownIndividually: Swift.Bool, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> (), _: (NIOPosix.SelectableEventLoop) -> ()) -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:87
0x55e66c6bf257, closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /build/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:107
0x55e66c6c1985, partial apply forwarder for closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /build/<compiler-generated>:0
0x55e66c6c1c79, reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /build/<compiler-generated>:0
0x55e66c6c199d, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /build/<compiler-generated>:0
0x55e66c6ed4e5, closure #1 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in static NIOPosix.ThreadOpsPosix.run(handle: inout Swift.Optional<Swift.UInt>, args: NIOPosix.Box<(body: (NIOPosix.NIOThread) -> (), name: Swift.Optional<Swift.String>)>, detachThread: Swift.Bool) -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:105
0x7fc6fc3ef608
0x7fc6fb860162
0xffffffffffffffff
It happened today again
[ INFO ] GET /apiv1/notifications/postlikes [request-id: A87FD5EC-E02F-4C32-BC1F-69BC1958FE72]
Received signal 4. Backtrace:
[ INFO ] POST /apiv1/post/like [request-id: 8B175D1F-0C9B-4E69-8C78-6E28CA9EB882]
๐ User: CCB0931D-39FF-483B-B43C-E0583C76C21D, likes repost. postId: 6C8B0BA7-5306-441C-968C-6A8F4E3858FC, repostId: FF484CF0-BE5F-4EFA-825F-A9AC46B6A7EB
Error?? post already liked?
[ WARNING ] Abort.204: No Content [request-id: 8B175D1F-0C9B-4E69-8C78-6E28CA9EB882]
0x564839986d32, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /build/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
0x7f2e63c453bf
0x56483986210a, Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag+StateMachine.swift:0
0x56483986210a, generic specialization <NIOCore.ByteBuffer> of NIOCore.CircularBuffer.removeFirst() -> A at /build/<compiler-generated>:0
0x56483986210a, AsyncHTTPClient.RequestBag.StateMachine.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> Swift.Optional<NIOCore.ByteBuffer> at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag+StateMachine.swift:311
0x5648398695b4, AsyncHTTPClient.RequestBag.(receiveResponseBodyParts0 in _828EC98A744D86D088B343098CA6B2A6)(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag.swift:215
0x56483986ca19, closure #1 () -> () in AsyncHTTPClient.RequestBag.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/.build/checkouts/async-http-client/Sources/AsyncHTTPClient/RequestBag.swift:423
0x56483986ca19, partial apply forwarder for closure #1 () -> () in AsyncHTTPClient.RequestBag.receiveResponseBodyParts(NIOCore.CircularBuffer<NIOCore.ByteBuffer>) -> () at /build/<compiler-generated>:0
0x564839ef12ab, reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /build/<compiler-generated>:0
0x564839ef12ab, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ()) at /build/<compiler-generated>:0
0x564839eec4a0, reabstraction thunk helper from @escaping @callee_guaranteed () -> (@out ()) to @escaping @callee_guaranteed () -> () at /build/<compiler-generated>:0
0x564839eec4a0, closure #4 () -> () in NIOPosix.SelectableEventLoop.run() throws -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:509
0x564839eec4a0, reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error) at /build/<compiler-generated>:0
0x564839eec4a0, generic specialization <()> of NIOPosix.withAutoReleasePool<A>(() throws -> A) throws -> A at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:28
0x564839eec4a0, NIOPosix.SelectableEventLoop.run() throws -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:508
0x564839ed7457, static NIOPosix.MultiThreadedEventLoopGroup.(runTheLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(thread: NIOPosix.NIOThread, canEventLoopBeShutdownIndividually: Swift.Bool, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> (), _: (NIOPosix.SelectableEventLoop) -> ()) -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:87
0x564839ed7457, closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /build/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:107
0x564839ed9b85, partial apply forwarder for closure #1 (NIOPosix.NIOThread) -> () in static NIOPosix.MultiThreadedEventLoopGroup.(setupThreadAndEventLoop in _C2B1528F4FBA68A3DBFA89DBAEBE9D4D)(name: Swift.String, selectorFactory: () throws -> NIOPosix.Selector<NIOPosix.NIORegistration>, initializer: (NIOPosix.NIOThread) -> ()) -> NIOPosix.SelectableEventLoop at /build/<compiler-generated>:0
0x564839ed9e79, reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /build/<compiler-generated>:0
0x564839ed9b9d, partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed NIOPosix.NIOThread) -> () to @escaping @callee_guaranteed (@in_guaranteed NIOPosix.NIOThread) -> (@out ()) at /build/<compiler-generated>:0
0x564839f056e5, closure #1 (Swift.Optional<Swift.UnsafeMutableRawPointer>) -> Swift.Optional<Swift.UnsafeMutableRawPointer> in static NIOPosix.ThreadOpsPosix.run(handle: inout Swift.Optional<Swift.UInt>, args: NIOPosix.Box<(body: (NIOPosix.NIOThread) -> (), name: Swift.Optional<Swift.String>)>, detachThread: Swift.Bool) -> () at /build/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:105
0x7f2e63c39608
0x7f2e630aa162
0xffffffffffffffff
I updated from 1.6.3 to latest. Hopefully i wont see this error again
For us (@ccmwa) the update to 1.10 didn't help, unfortunately.
Thanks for this report. Yeah, this looks like a straightforward bug: when we receive a HTTP response end we'll pass the buffered reads directly to the ResponseBag, which does not expect there to be no buffers. Should be easy enough to test and fix.
@Lukasa
And easy fix? thanks you! I really appreciate it.
If it were a rare bug i wouldnt mind too much. But it happened twice in such a short time, so I am kinda nervous as my app is already being tested in prod
awesome, got a release date for this patch? or should i just point to the github commit in my swift package in the mean time?
I don't have a specific date, but we'd like to release this week.