We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSan on Swift 4.2 on macOS complains about data races in testPipelining:
testPipelining
Test Case '-[KituraNetTests.PipeliningTests testPipelining]' started. ================== WARNING: ThreadSanitizer: data race (pid=75673) Read of size 8 at 0x7b080003f1d0 by thread T30: #0 Delegate.handle(request:response:) PipeliningTests.swift:126 (KituraNetPackageTests:x86_64+0x10c4f9) #1 protocol witness for ServerDelegate.handle(request:response:) in conformance Delegate <compiler-generated> (KituraNetPackageTests:x86_64+0x10ced6) #2 closure #1 in HTTPRequestHandler.channelRead(ctx:data:) HTTPRequestHandler.swift:86 (KituraNetPackageTests:x86_64+0x54f7a) #3 partial apply for closure #1 in HTTPRequestHandler.channelRead(ctx:data:) <compiler-generated> (KituraNetPackageTests:x86_64+0x5501d) #4 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x3a060) #5 __tsan::invoke_and_release_block(void*) <null>:10184352 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x685ab) #6 _dispatch_client_callout <null>:10184352 (libdispatch.dylib:x86_64+0x3dce) Previous write of size 8 at 0x7b080003f1d0 by thread T31: #0 Delegate.handle(request:response:) PipeliningTests.swift:130 (KituraNetPackageTests:x86_64+0x10c7e7) #1 protocol witness for ServerDelegate.handle(request:response:) in conformance Delegate <compiler-generated> (KituraNetPackageTests:x86_64+0x10ced6) #2 closure #1 in HTTPRequestHandler.channelRead(ctx:data:) HTTPRequestHandler.swift:86 (KituraNetPackageTests:x86_64+0x54f7a) #3 partial apply for closure #1 in HTTPRequestHandler.channelRead(ctx:data:) <compiler-generated> (KituraNetPackageTests:x86_64+0x5501d) #4 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x3a060) #5 __tsan::invoke_and_release_block(void*) <null>:10184352 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x685ab) #6 _dispatch_client_callout <null>:10184352 (libdispatch.dylib:x86_64+0x3dce) Location is heap block of size 24 at 0x7b080003f1c0 allocated by main thread: #0 malloc <null>:10184384 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x4adca) #1 swift_slowAlloc <null>:10184384 (libswiftCore.dylib:x86_64+0x3093f8) #2 PipeliningTests.testPipelining() PipeliningTests.swift:48 (KituraNetPackageTests:x86_64+0x106ba5) #3 @objc PipeliningTests.testPipelining() <compiler-generated> (KituraNetPackageTests:x86_64+0x109470) #4 __invoking___ <null>:10184384 (CoreFoundation:x86_64h+0x4ad1b) Thread T30 (tid=24724834, running) is a GCD worker thread Thread T31 (tid=24724833, running) is a GCD worker thread SUMMARY: ThreadSanitizer: data race PipeliningTests.swift:126 in Delegate.handle(request:response:) ================== ================== WARNING: ThreadSanitizer: Swift access race (pid=75673) Modifying access of Swift variable at 0x7b10000ed470 by thread T24: #0 HTTPRequestHandler.updateKeepAliveState() HTTPRequestHandler.swift:135 (KituraNetPackageTests:x86_64+0x562f7) #1 HTTPServerResponse.sendResponse(channel:handler:status:withBody:) HTTPServerResponse.swift:193 (KituraNetPackageTests:x86_64+0x771b7) #2 closure #1 in HTTPServerResponse.end() HTTPServerResponse.swift:146 (KituraNetPackageTests:x86_64+0x75063) #3 partial apply for closure #1 in HTTPServerResponse.end() <compiler-generated> (KituraNetPackageTests:x86_64+0x7543e) #4 closure #1 in HTTPServerResponse.execute(on:_:) HTTPServerResponse.swift:106 (KituraNetPackageTests:x86_64+0x73762) #5 partial apply for closure #1 in HTTPServerResponse.execute(on:_:) <compiler-generated> (KituraNetPackageTests:x86_64+0x7888b) #6 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x8b1b4) #7 thunk for @escaping @callee_guaranteed () -> ()partial apply <compiler-generated> (KituraNetPackageTests:x86_64+0x21e598) #8 thunk for @escaping @callee_guaranteed (@in_guaranteed ()) -> (@out ()) <compiler-generated> (KituraNetPackageTests:x86_64+0x89f67) #9 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed ()) -> (@out ()) <compiler-generated> (KituraNetPackageTests:x86_64+0x2111fb) #10 closure #3 in SelectableEventLoop.run() EventLoop.swift:705 (KituraNetPackageTests:x86_64+0x210fe2) #11 partial apply for closure #3 in SelectableEventLoop.run() <compiler-generated> (KituraNetPackageTests:x86_64+0x21108b) #12 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (KituraNetPackageTests:x86_64+0x143926) #13 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (KituraNetPackageTests:x86_64+0x21113e) #14 closure #1 in withAutoReleasePool<A>(_:) EventLoop.swift:430 (KituraNetPackageTests:x86_64+0x2087a8) #15 partial apply for closure #1 in withAutoReleasePool<A>(_:) <compiler-generated> (KituraNetPackageTests:x86_64+0x21e659) #16 autoreleasepool<A>(invoking:) <null>:11253008 (libswiftObjectiveC.dylib:x86_64+0x3f2e) #17 SelectableEventLoop.run() EventLoop.swift:704 (KituraNetPackageTests:x86_64+0x20f571) #18 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) EventLoop.swift:871 (KituraNetPackageTests:x86_64+0x215182) #19 partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) <compiler-generated> (KituraNetPackageTests:x86_64+0x21dc39) #20 thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x215b7b) #21 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x2fc528) #22 closure #1 in static Thread.spawnAndRun(name:body:) Thread.swift:105 (KituraNetPackageTests:x86_64+0x2fcee4) #23 @objc closure #1 in static Thread.spawnAndRun(name:body:) <compiler-generated> (KituraNetPackageTests:x86_64+0x2fcf90) Previous read of size 8 at 0x7b10000ed470 by thread T30: #0 HTTPRequestHandler.keepAliveState.getter <compiler-generated> (KituraNetPackageTests:x86_64+0x52d26) #1 HTTPServerResponse.end() HTTPServerResponse.swift:137 (KituraNetPackageTests:x86_64+0x73ed2) #2 HTTPServerResponse.end(text:) HTTPServerResponse.swift:116 (KituraNetPackageTests:x86_64+0x7388a) #3 protocol witness for ServerResponse.end(text:) in conformance HTTPServerResponse <compiler-generated> (KituraNetPackageTests:x86_64+0x7819f) #4 Delegate.handle(request:response:) PipeliningTests.swift:126 (KituraNetPackageTests:x86_64+0x10c6e0) #5 protocol witness for ServerDelegate.handle(request:response:) in conformance Delegate <compiler-generated> (KituraNetPackageTests:x86_64+0x10ced6) #6 closure #1 in HTTPRequestHandler.channelRead(ctx:data:) HTTPRequestHandler.swift:86 (KituraNetPackageTests:x86_64+0x54f7a) #7 partial apply for closure #1 in HTTPRequestHandler.channelRead(ctx:data:) <compiler-generated> (KituraNetPackageTests:x86_64+0x5501d) #8 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x3a060) #9 __tsan::invoke_and_release_block(void*) <null>:11253008 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x685ab) #10 _dispatch_client_callout <null>:11253008 (libdispatch.dylib:x86_64+0x3dce) Location is heap block of size 59 at 0x7b10000ed440 allocated by thread T24: #0 malloc <null>:11253040 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x4adca) #1 swift_slowAlloc <null>:11253040 (libswiftCore.dylib:x86_64+0x3093f8) #2 closure #1 in HTTPServer.listen(on:) HTTPServer.swift:172 (KituraNetPackageTests:x86_64+0x61479) #3 partial apply for closure #1 in HTTPServer.listen(on:) <compiler-generated> (KituraNetPackageTests:x86_64+0x61d38) #4 thunk for @escaping @callee_guaranteed (@guaranteed Channel) -> (@owned EventLoopFuture<()>) <compiler-generated> (KituraNetPackageTests:x86_64+0x16909b) #5 thunk for @escaping @callee_guaranteed (@guaranteed Channel) -> (@owned EventLoopFuture<()>)partial apply <compiler-generated> (KituraNetPackageTests:x86_64+0x179508) #6 thunk for @escaping @callee_guaranteed (@in_guaranteed Channel) -> (@out EventLoopFuture<()>) <compiler-generated> (KituraNetPackageTests:x86_64+0x1691b7) #7 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Channel) -> (@out EventLoopFuture<()>) <compiler-generated> (KituraNetPackageTests:x86_64+0x178e88) #8 closure #1 in setupChildChannel #1 () in ServerBootstrap.AcceptHandler.channelRead(ctx:data:) Bootstrap.swift:263 (KituraNetPackageTests:x86_64+0x16b85a) #9 partial apply for closure #1 in setupChildChannel #1 () in ServerBootstrap.AcceptHandler.channelRead(ctx:data:) <compiler-generated> (KituraNetPackageTests:x86_64+0x1795c7) #10 thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>) <compiler-generated> (KituraNetPackageTests:x86_64+0x356a4) #11 thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>)partial apply <compiler-generated> (KituraNetPackageTests:x86_64+0x179680) #12 closure #1 in EventLoopFuture.then<A>(file:line:_:) EventLoopFuture.swift:442 (KituraNetPackageTests:x86_64+0x225a74) #13 partial apply for closure #1 in EventLoopFuture.then<A>(file:line:_:) <compiler-generated> (KituraNetPackageTests:x86_64+0x225ffe) #14 EventLoopFuture._addCallback(_:) EventLoopFuture.swift:597 (KituraNetPackageTests:x86_64+0x226882) #15 EventLoopFuture._whenComplete(_:) EventLoopFuture.swift:603 (KituraNetPackageTests:x86_64+0x226ba8) #16 EventLoopFuture.then<A>(file:line:_:) EventLoopFuture.swift:439 (KituraNetPackageTests:x86_64+0x225634) #17 setupChildChannel #1 () in ServerBootstrap.AcceptHandler.channelRead(ctx:data:) Bootstrap.swift:261 (KituraNetPackageTests:x86_64+0x16b687) #18 closure #2 in ServerBootstrap.AcceptHandler.channelRead(ctx:data:) Bootstrap.swift:287 (KituraNetPackageTests:x86_64+0x16c385) #19 partial apply for closure #2 in ServerBootstrap.AcceptHandler.channelRead(ctx:data:) <compiler-generated> (KituraNetPackageTests:x86_64+0x1792cb) #20 thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>, @error @owned Error) <compiler-generated> (KituraNetPackageTests:x86_64+0x16c3fd) #21 partial apply for thunk for @escaping @callee_guaranteed () -> (@owned EventLoopFuture<()>, @error @owned Error) <compiler-generated> (KituraNetPackageTests:x86_64+0x17938e) #22 closure #1 in EventLoop.submit<A>(_:) EventLoop.swift:306 (KituraNetPackageTests:x86_64+0x20725d) #23 partial apply for closure #1 in EventLoop.submit<A>(_:) <compiler-generated> (KituraNetPackageTests:x86_64+0x207459) #24 thunk for @escaping @callee_guaranteed () -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x8b1b4) #25 thunk for @escaping @callee_guaranteed () -> ()partial apply <compiler-generated> (KituraNetPackageTests:x86_64+0x21e598) #26 thunk for @escaping @callee_guaranteed (@in_guaranteed ()) -> (@out ()) <compiler-generated> (KituraNetPackageTests:x86_64+0x89f67) #27 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed ()) -> (@out ()) <compiler-generated> (KituraNetPackageTests:x86_64+0x2111fb) #28 closure #3 in SelectableEventLoop.run() EventLoop.swift:705 (KituraNetPackageTests:x86_64+0x210fe2) #29 partial apply for closure #3 in SelectableEventLoop.run() <compiler-generated> (KituraNetPackageTests:x86_64+0x21108b) #30 thunk for @callee_guaranteed () -> (@error @owned Error) <compiler-generated> (KituraNetPackageTests:x86_64+0x143926) #31 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply <compiler-generated> (KituraNetPackageTests:x86_64+0x21113e) #32 closure #1 in withAutoReleasePool<A>(_:) EventLoop.swift:430 (KituraNetPackageTests:x86_64+0x2087a8) #33 partial apply for closure #1 in withAutoReleasePool<A>(_:) <compiler-generated> (KituraNetPackageTests:x86_64+0x21e659) #34 autoreleasepool<A>(invoking:) <null>:11253040 (libswiftObjectiveC.dylib:x86_64+0x3f2e) #35 SelectableEventLoop.run() EventLoop.swift:704 (KituraNetPackageTests:x86_64+0x20f571) #36 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) EventLoop.swift:871 (KituraNetPackageTests:x86_64+0x215182) #37 partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) <compiler-generated> (KituraNetPackageTests:x86_64+0x21dc39) #38 thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x215b7b) #39 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed Thread) -> () <compiler-generated> (KituraNetPackageTests:x86_64+0x2fc528) #40 closure #1 in static Thread.spawnAndRun(name:body:) Thread.swift:105 (KituraNetPackageTests:x86_64+0x2fcee4) #41 @objc closure #1 in static Thread.spawnAndRun(name:body:) <compiler-generated> (KituraNetPackageTests:x86_64+0x2fcf90) Thread T24 (tid=24725091, running) created by main thread at: #0 pthread_create <null>:11253088 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2936d) #1 static Thread.spawnAndRun(name:body:) Thread.swift:90 (KituraNetPackageTests:x86_64+0x2fb9ae) #2 static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:initializer:) EventLoop.swift:857 (KituraNetPackageTests:x86_64+0x214a5f) #3 closure #1 in MultiThreadedEventLoopGroup.init(threadInitializers:) EventLoop.swift:911 (KituraNetPackageTests:x86_64+0x2164f6) #4 partial apply for closure #1 in MultiThreadedEventLoopGroup.init(threadInitializers:) <compiler-generated> (KituraNetPackageTests:x86_64+0x216624) #5 thunk for @callee_guaranteed (@guaranteed @escaping @callee_guaranteed (@guaranteed Thread) -> ()) -> (@owned SelectableEventLoop, @error @owned Error) <compiler-generated> (KituraNetPackageTests:x86_64+0x21673f) #6 partial apply for thunk for @callee_guaranteed (@guaranteed @escaping @callee_guaranteed (@guaranteed Thread) -> ()) -> (@owned SelectableEventLoop, @error @owned Error) <compiler-generated> (KituraNetPackageTests:x86_64+0x2168b9) #7 Collection.map<A>(_:) <null>:11253088 (libswiftCore.dylib:x86_64+0x1f50e) #8 MultiThreadedEventLoopGroup.init(numberOfThreads:) EventLoop.swift:891 (KituraNetPackageTests:x86_64+0x215ac3) #9 MultiThreadedEventLoopGroup.__allocating_init(numberOfThreads:) EventLoop.swift (KituraNetPackageTests:x86_64+0x2159a8) #10 HTTPServer.init() HTTPServer.swift:69 (KituraNetPackageTests:x86_64+0x58f16) #11 HTTPServer.__allocating_init() HTTPServer.swift (KituraNetPackageTests:x86_64+0x58998) #12 PipeliningTests.testPipelining() PipeliningTests.swift:47 (KituraNetPackageTests:x86_64+0x106b5f) #13 @objc PipeliningTests.testPipelining() <compiler-generated> (KituraNetPackageTests:x86_64+0x109470) #14 __invoking___ <null>:11253088 (CoreFoundation:x86_64h+0x4ad1b) Thread T30 (tid=24724834, running) is a GCD worker thread SUMMARY: ThreadSanitizer: Swift access race HTTPRequestHandler.swift:135 in HTTPRequestHandler.updateKeepAliveState() ================== Test Case '-[KituraNetTests.PipeliningTests testPipelining]' passed (0.406 seconds).
# on macOS cd Kitura-NIO swift test --sanitize=thread
The text was updated successfully, but these errors were encountered:
Thanks @weissi for the bug report. Synchronising access to keepAliveState seems to be the only solution here.
keepAliveState
Sorry, something went wrong.
No branches or pull requests
TSan on Swift 4.2 on macOS complains about data races in
testPipelining
:problem
repro
The text was updated successfully, but these errors were encountered: