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.99k stars 651 forks source link

Occasional program crashes on ubuntu20.04 #2668

Closed shenfu1991 closed 9 months ago

shenfu1991 commented 9 months ago

Expected behavior

[what you expected to happen] Running well

Actual behavior

[what actually happened] crashed

Steps to reproduce

This is a quantification program running on swift vapor. It crashed suddenly after running for a few days, and the phenomenon could not be reproduced immediately.

If possible, minimal yet complete reproducer code (or URL to code)

[anything to help us reproducing the issue]

SwiftNIO version/commit hash

[the SwiftNIO tag/commit hash]

System & version information

Please provide at the very least your operating system and Swift version information.

Ideally, run

scripts/nio-diagnose -o nio-diagnose.md PID_OF_YOUR_NIO_PROGRAM

and attach (or paste) the resulting file nio-diagnose.md into this bug report or send it to the SwiftNIO maintainers privately.

OS: ubuntu20.04 swift-nio vertsion: 2.63.0 Swift version 5.9.2 (swift-5.9.2-RELEASE) Target: x86_64-unknown-linux-gnu

crash log:

*** Signal 11: Backtracing from 0x7fcf719240b3... done ***

*** Program crashed: Bad pointer dereference at 0x0000000000000000 ***

Thread 0 "tbx_4":

0  0x00007fcf7040880a  in libc.so.6

Thread 1 "NIO-ELT-0-#0":

0                0x00007fcf704ebe2e  in libc.so.6
1 [ra] [system]  0x0000562f234240b1 specialized Selector.whenReady0(strategy:onLoopBegin:_:) + 624 in tbx_4 at /root/tbx_4/x-bot/
2 [ra] [inlined] 0x0000562f23420b5a specialized Selector.whenReady(strategy:onLoopBegin:_:) in tbx_4 at .build/checkouts/swift-nio/Sources/NIOPosix/SelectorGeneric.swift:288:18
3 [ra]           0x0000562f23420b5a SelectableEventLoop.run() + 521 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:470:36
4 [ra] [inlined] 0x0000562f233f9b63 static MultiThreadedEventLoopGroup.runTheLoop(thread:parentGroup:canEventLoopBeShutdownIndividually:selectorFactory:initializer:_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:93:22
5 [ra]           0x0000562f233f9b63 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 322 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:111:41
6 [ra] [thunk]   0x0000562f233fd17a partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 41 in tbx_4 at /root/tbx_4/x-bot/
7 [ra] [thunk]   0x0000562f233ff69f thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () + 14 in tbx_4 at /root/tbx_4/x-bot/
8 [ra]           0x0000562f2343cb6d closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) + 380 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:116:13

Thread 2 "NIO-ELT-0-#1":

0                0x00007fcf704ebe2e  in libc.so.6
1 [ra] [system]  0x0000562f234240b1 specialized Selector.whenReady0(strategy:onLoopBegin:_:) + 624 in tbx_4 at /root/tbx_4/x-bot/
2 [ra] [inlined] 0x0000562f23420b5a specialized Selector.whenReady(strategy:onLoopBegin:_:) in tbx_4 at .build/checkouts/swift-nio/Sources/NIOPosix/SelectorGeneric.swift:288:18
3 [ra]           0x0000562f23420b5a SelectableEventLoop.run() + 521 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:470:36
4 [ra] [inlined] 0x0000562f233f9b63 static MultiThreadedEventLoopGroup.runTheLoop(thread:parentGroup:canEventLoopBeShutdownIndividually:selectorFactory:initializer:_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:93:22
5 [ra]           0x0000562f233f9b63 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 322 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:111:41
6 [ra] [thunk]   0x0000562f233fd17a partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 41 in tbx_4 at /root/tbx_4/x-bot/
7 [ra] [thunk]   0x0000562f233ff69f thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () + 14 in tbx_4 at /root/tbx_4/x-bot/
8 [ra]           0x0000562f2343cb6d closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) + 380 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:116:13

Thread 3 "NIO-ELT-0-#2":

0                0x00007fcf704ebe2e  in libc.so.6
1 [ra] [system]  0x0000562f234240b1 specialized Selector.whenReady0(strategy:onLoopBegin:_:) + 624 in tbx_4 at /root/tbx_4/x-bot/
2 [ra] [inlined] 0x0000562f23420b5a specialized Selector.whenReady(strategy:onLoopBegin:_:) in tbx_4 at .build/checkouts/swift-nio/Sources/NIOPosix/SelectorGeneric.swift:288:18
3 [ra]           0x0000562f23420b5a SelectableEventLoop.run() + 521 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:470:36
4 [ra] [inlined] 0x0000562f233f9b63 static MultiThreadedEventLoopGroup.runTheLoop(thread:parentGroup:canEventLoopBeShutdownIndividually:selectorFactory:initializer:_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:93:22
5 [ra]           0x0000562f233f9b63 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 322 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:111:41
6 [ra] [thunk]   0x0000562f233fd17a partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 41 in tbx_4 at /root/tbx_4/x-bot/
7 [ra] [thunk]   0x0000562f233ff69f thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () + 14 in tbx_4 at /root/tbx_4/x-bot/
8 [ra]           0x0000562f2343cb6d closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) + 380 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:116:13

Thread 4 "NIO-ELT-0-#3" crashed:

 0                         0x00007fcf719240b3 swift::RefCounts >::incrementSlow(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 35 in libswiftCore.so
 1 [ra]                    0x00007fcf7192bfbb swift_bridgeObjectRetain + 26 in libswiftCore.so
 2 [ra] [system]           0x0000562f2368c538 getDetails #1 (vc:) in routes(_:) + 743 in tbx_4 at /root/tbx_4/x-bot/
 3 [ra] [inlined]          0x0000562f2368d60c specialized Sequence.forEach(_:) in tbx_4 at /root/tbx_4/x-bot/Sources/tbx_4/routes.swift:171:24
 4 [ra]                    0x0000562f2368d60c closure #7 in routes(_:) + 219 in tbx_4 at /root/tbx_4/x-bot/Sources/tbx_4/routes.swift:170:17
 5 [ra] [thunk]            0x0000562f235a6885 partial apply for closure #1 in closure #1 in RoutesBuilder.on(_:_:body:use:) + 20 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/Routing/RoutesBuilder+Method.swift:170:25
 6 [ra]                    0x0000562f23246b27 closure #1 in EventLoopFuture._flatMapThrowing(_:) + 486 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:528:33
 7 [ra]                    0x0000562f23243cc8 EventLoopFuture._addCallback(_:) + 247 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:748:16
 8 [ra]                    0x0000562f23247cc5 EventLoopFuture._internalWhenComplete(_:) + 68 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:763:18
 9 [ra]                    0x0000562f2324691e EventLoopFuture._flatMap(_:) + 157 in tbx_4
10 [ra]                    0x0000562f235a6619 closure #1 in RoutesBuilder.on(_:_:body:use:) + 424 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/Routing/RoutesBuilder+Method.swift:169:19
11 [ra] [thunk]            0x0000562f235a66ce partial apply for closure #1 in RoutesBuilder.on(_:_:body:use:) + 61 in tbx_4 at /root/tbx_4/x-bot/
12 [ra] [inlined]          0x0000562f2351cb3e BasicResponder.respond(to:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/HTTP/BasicResponder.swift:26:24
13 [ra] [thunk]            0x0000562f2351cb3e protocol witness for Responder.respond(to:) in conformance BasicResponder + 29 in tbx_4 at /root/tbx_4/x-bot/:24:17
14 [ra] [inlined]          0x0000562f2357bdd9 ErrorMiddleware.respond(to:chainingTo:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/Middleware/ErrorMiddleware.swift:80:21
15 [ra] [thunk]            0x0000562f2357bdd9 protocol witness for Middleware.respond(to:chainingTo:) in conformance ErrorMiddleware + 56 in tbx_4 at /root/tbx_4/x-bot/:79:17
16 [ra] [inlined]          0x0000562f2357f065 HTTPMiddlewareResponder.respond(to:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/Middleware/Middleware.swift:50:32
17 [ra] [thunk]            0x0000562f2357f065 protocol witness for Responder.respond(to:) in conformance HTTPMiddlewareResponder + 52 in tbx_4 at /root/tbx_4/x-bot/:49:10
18 [ra]                    0x0000562f2357ff32 RouteLoggingMiddleware.respond(to:chainingTo:) + 1025 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/Middleware/RouteLoggingMiddleware.swift:15:21
19 [ra] [thunk]            0x0000562f23580070 protocol witness for Middleware.respond(to:chainingTo:) in conformance RouteLoggingMiddleware + 15 in tbx_4 at /root/tbx_4/x-bot/
20 [ra] [inlined]          0x0000562f2357f065 HTTPMiddlewareResponder.respond(to:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/Middleware/Middleware.swift:50:32
21 [ra] [thunk]            0x0000562f2357f065 protocol witness for Responder.respond(to:) in conformance HTTPMiddlewareResponder + 52 in tbx_4 at /root/tbx_4/x-bot/:49:10
22 [ra]                    0x0000562f2359b359 DefaultResponder.respond(to:) + 248 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/Responder/DefaultResponder.swift:75:46
23 [ra]                    0x0000562f23565a16 HTTPServerHandler.channelRead(context:data:) + 181 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/HTTP/Server/HTTPServerHandler.swift:22:24
24 [ra]                    0x0000562f23228d86 ChannelHandlerContext.invokeChannelRead(_:) + 37 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1696:28
25 [ra]                    0x0000562f23226093 ChannelHandlerContext.fireChannelRead(_:) + 34 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1509:20
26 [ra]                    0x0000562f2356f6ca HTTPServerUpgradeHandler.channelRead(context:data:) + 649 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/HTTP/Server/HTTPServerUpgradeHandler.swift:43:17
27 [ra]                    0x0000562f23228d86 ChannelHandlerContext.invokeChannelRead(_:) + 37 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1696:28
28 [ra]                    0x0000562f23226093 ChannelHandlerContext.fireChannelRead(_:) + 34 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1509:20
29 [ra]                    0x0000562f23568dd9 HTTPServerRequestDecoder.channelRead(context:data:) + 1880 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/vapor/Sources/Vapor/HTTP/Server/HTTPServerRequestDecoder.swift:96:25
30 [ra]                    0x0000562f23228d86 ChannelHandlerContext.invokeChannelRead(_:) + 37 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1696:28
31 [ra]                    0x0000562f23228da4 ChannelHandlerContext.invokeChannelRead(_:) + 67 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1698:24
32 [ra]                    0x0000562f23226093 ChannelHandlerContext.fireChannelRead(_:) + 34 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1509:20
33 [ra]                    0x0000562f232cb6d7 HTTPServerPipelineHandler.deliverOneMessage(context:data:) + 550 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPServerPipelineHandler.swift:339:17
34 [ra]                    0x0000562f232cb3ff HTTPServerPipelineHandler.channelRead(context:data:) + 142 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPServerPipelineHandler.swift:295:46
35 [ra]                    0x0000562f23228d86 ChannelHandlerContext.invokeChannelRead(_:) + 37 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1696:28
36 [ra]                    0x0000562f23226093 ChannelHandlerContext.fireChannelRead(_:) + 34 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1509:20
37 [ra] [system]           0x0000562f232bc164 HTTPDecoder.didFinishMessage() + 243 in tbx_4 at /root/tbx_4/x-bot/
38 [ra] [thunk]            0x0000562f232bc860 protocol witness for HTTPDecoderDelegate.didFinishMessage() in conformance HTTPDecoder + 15 in tbx_4 at /root/tbx_4/x-bot/
39 [ra]                    0x0000562f232baa38 BetterHTTPParser.didReceiveMessageCompleteNotification() + 343 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:256:23
40 [ra] [thunk]            0x0000562f232ba005 @objc closure #10 in BetterHTTPParser.init(kind:) + 36 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:115:49
41 [ra]                    0x0000562f230d94e1 c_nio_llhttp__internal__run + 20912 in tbx_4 at .build/checkouts/swift-nio/Sources/CNIOLLHTTP/c_nio_llhttp.c:7151:13
42 [ra]                    0x0000562f230d42ed c_nio_llhttp__internal_execute + 60 in tbx_4 at .build/checkouts/swift-nio/Sources/CNIOLLHTTP/c_nio_llhttp.c:9521:10
43 [ra] [inlined]          0x0000562f232bb1ed c_nio_llhttp_execute_swift in tbx_4 at .build/checkouts/swift-nio/Sources/CNIOLLHTTP/include/CNIOLLHTTP.h:25:12
44 [ra]                    0x0000562f232bb1ed closure #1 in BetterHTTPParser.feedInput(_:) + 92 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:390:22
45 [ra] [inlined]          0x0000562f232bb04a specialized BetterHTTPParser.withExclusiveHTTPParser(_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:373:16
46 [ra]                    0x0000562f232bb04a BetterHTTPParser.feedInput(_:) + 201 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:378:48
47 [ra] [inlined]          0x0000562f232bc400 specialized ByteBuffer.withUnsafeReadableBytes(_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:712:29
48 [ra]                    0x0000562f232bc400 HTTPDecoder.feedInput(context:buffer:) + 271 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:711:35
49 [ra]                    0x0000562f232bc4a0 HTTPDecoder.decode(context:buffer:) + 15 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOHTTP1/HTTPDecoder.swift:719:22
50 [ra] [thunk]            0x0000562f232bc6c0 protocol witness for ByteToMessageDecoder.decode(context:buffer:) in conformance HTTPDecoder + 15 in tbx_4 at /root/tbx_4/x-bot/
51 [ra]                    0x0000562f23236fd7 closure #1 in ByteToMessageHandler.decodeLoop(context:decodeMode:) + 54 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/Codec.swift:580:49
52 [ra] [inlined]          0x0000562f23236d93 ByteToMessageHandler.withNextBuffer(allowEmptyBuffer:_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/Codec.swift:537:36
53 [ra]                    0x0000562f23236d93 ByteToMessageHandler.decodeLoop(context:decodeMode:) + 1202 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/Codec.swift:576:35
54 [ra]                    0x0000562f232375f1 ByteToMessageHandler.channelRead(context:data:) + 240 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/Codec.swift:649:29
55 [ra]                    0x0000562f23228d86 ChannelHandlerContext.invokeChannelRead(_:) + 37 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1696:28
56 [ra]                    0x0000562f23228da4 ChannelHandlerContext.invokeChannelRead(_:) + 67 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1698:24
57 [ra] [inlined]          0x0000562f23229bbc ChannelPipeline.fireChannelRead0(_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:897:29
58 [ra]                    0x0000562f23229bbc ChannelPipeline.SynchronousOperations.fireChannelRead(_:) + 43 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOCore/ChannelPipeline.swift:1160:28
59 [ra]                    0x0000562f233c7ff9 BaseStreamSocketChannel.readFromSocket() + 840 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/BaseStreamSocketChannel.swift:133:50
60 [ra]                    0x0000562f23420450 specialized BaseSocketChannel.readable0() + 31 in tbx_4
61 [ra] [inlined]          0x0000562f2342760a specialized BaseSocketChannel.readable() in tbx_4 at .build/checkouts/swift-nio/Sources/NIOPosix/BaseSocketChannel.swift:1099:14
62 [ra] [inlined] [system] 0x0000562f2342760a specialized protocol witness for SelectableChannel.readable() in conformance BaseSocketChannel in tbx_4 at /root/tbx_4/x-bot/:1096:23
63 [ra]                    0x0000562f2342760a specialized SelectableEventLoop.handleEvent(_:channel:) + 153 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:403:25
64 [ra] [inlined] [system] 0x0000562f23422b90 specialized SelectableEventLoop.handleEvent(_:channel:) in tbx_4 at /root/tbx_4/x-bot/
65 [ra]                    0x0000562f23422b90 closure #2 in closure #2 in SelectableEventLoop.run() + 159 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:478:30
66 [ra] [thunk]            0x0000562f2342aaec partial apply for closure #2 in closure #2 in SelectableEventLoop.run() + 11 in tbx_4 at /root/tbx_4/x-bot/
67 [ra]                    0x0000562f23424283 specialized Selector.whenReady0(strategy:onLoopBegin:_:) + 1090 in tbx_4 at .build/checkouts/swift-nio/Sources/NIOPosix/SelectorEpoll.swift:252:25
68 [ra] [inlined]          0x0000562f23420b5a specialized Selector.whenReady(strategy:onLoopBegin:_:) in tbx_4 at .build/checkouts/swift-nio/Sources/NIOPosix/SelectorGeneric.swift:288:18
69 [ra]                    0x0000562f23420b5a SelectableEventLoop.run() + 521 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:470:36
70 [ra] [inlined]          0x0000562f233f9b63 static MultiThreadedEventLoopGroup.runTheLoop(thread:parentGroup:canEventLoopBeShutdownIndividually:selectorFactory:initializer:_:) in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:93:22
71 [ra]                    0x0000562f233f9b63 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 322 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:111:41
72 [ra] [thunk]            0x0000562f233fd17a partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:) + 41 in tbx_4 at /root/tbx_4/x-bot/
73 [ra] [thunk]            0x0000562f233ff69f thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () + 14 in tbx_4 at /root/tbx_4/x-bot/
74 [ra]                    0x0000562f2343cb6d closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) + 380 in tbx_4 at /root/tbx_4/x-bot/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:116:13

Thread 5 "TP-#0":

0  0x00007fcf70457117  in libc.so.6

Thread 6 "TP-#1":

0  0x00007fcf70457117  in libc.so.6

Thread 7 "TP-#2":

0  0x00007fcf70457117  in libc.so.6

Thread 8 "TP-#3":

0  0x00007fcf70457117  in libc.so.6

Thread 9:

0  0x00007fcf704ebe2e  in libc.so.6

Thread 10:

0  0x00007fcf70457117  in libc.so.6

Thread 11:

0  0x00007fcf70457117  in libc.so.6

Thread 12:

0  0x00007fcf70457117  in libc.so.6

Thread 13:

0  0x00007fcf70457117  in libc.so.6

Thread 14:

0  0x00007fcf70457117  in libc.so.6

Thread 15:

0  0x00007fcf70457117  in libc.so.6

Thread 16:

0  0x00007fcf70457117  in libc.so.6

Registers:

rax 0x0000000000000000  0
rdx 0x0000000000000000  0
rcx 0x0000000000000000  0
rbx 0x0000000000000000  0
rsi 0x00007fcf380a3388  a9 b2 88 41 9a ff 1a cb b0 02 00 00 00 00 00 80  ©²·A·ÿ·Ë°·······
rdi 0xcb1aff9a4188b2a9  14635290977083372201
rbp 0x00007fcf6cb2cfe0  00 d0 b2 6c cf 7f 00 00 bb bf 92 71 cf 7f 00 00  ·Ð²lÏ···»¿·qÏ···
rsp 0x00007fcf6cb2cfd0  80 33 0a 38 cf 7f 00 00 16 00 00 00 00 00 00 00  ·3·8Ï···········
 r8 0x0000000000000001  1
 r9 0x0000000000000000  0
r10 0x2000000000000000  2305843009213693952
r11 0xcb1aff9a4188b2a9  14635290977083372201
r12 0x3000000000000175  3458764513820541301
r13 0x00007fcf6cb2d078  75 01 00 00 00 00 00 30 50 ac 29 58 cf 7f 00 00  u······0P¬)XÏ···
r14 0x00007fcf380a3388  a9 b2 88 41 9a ff 1a cb b0 02 00 00 00 00 00 80  ©²·A·ÿ·Ë°·······
r15 0x00007fcf380a3380  f3 ae ee c4 c8 7f 00 00 a9 b2 88 41 9a ff 1a cb  ó®îÄÈ···©²·A·ÿ·Ë
rip 0x00007fcf719240b3  f0 48 0f c7 0c f5 10 00 00 00 41 83 f8 01 74 21  ðH·Ç·õ····A·ø·t!

rflags 0x0000000000010246  ZF PF

cs 0x0033  fs 0x0000  gs 0x0000

Images (16 omitted):

0x0000562f22b7f000–0x0000562f239ef0c0                             tbx_4           /root/tbx_4/x-bot/.build/x86_64-unknown-linux-gnu/release/tbx_4
0x00007fcf703c6000–0x00007fcf70582341 c289da5071a3399de893d2af81d6a30c62646e1e libc.so.6       /usr/lib/x86_64-linux-gnu/libc.so.6
0x00007fcf714d8000–0x00007fcf71a1f048                             libswiftCore.so /root/swift-core/usr/lib/swift/linux/libswiftCore.so

Backtrace took 48.45s
shenfu1991 commented 9 months ago

Because the program has crashed, the PID cannot be known and therefore the nio-diagnose.md file cannot be produced.

Lukasa commented 9 months ago

This crash is in your code:

 0                         0x00007fcf719240b3 swift::RefCounts >::incrementSlow(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 35 in libswiftCore.so
 1 [ra]                    0x00007fcf7192bfbb swift_bridgeObjectRetain + 26 in libswiftCore.so
 2 [ra] [system]           0x0000562f2368c538 getDetails #1 (vc:) in routes(_:) + 743 in tbx_4 at /root/tbx_4/x-bot/
 3 [ra] [inlined]          0x0000562f2368d60c specialized Sequence.forEach(_:) in tbx_4 at /root/tbx_4/x-bot/Sources/tbx_4/routes.swift:171:24

It is overwhelmingly likely that this is a thread-safety issue, where you are reading/modifying some state on multiple threads at the same time. That will lead to this crash on the retain call, where you are attempting to retain an object that has been deallocated. I recommend you use thread sanitizer to try to diagnose this issue. However, this is not a NIO bug.