davidstump / SwiftPhoenixClient

Connect your Phoenix and iOS applications through WebSockets!
MIT License
511 stars 147 forks source link

Data #191

Closed JetForMe closed 3 years ago

JetForMe commented 3 years ago

This might be related to #188, but Xcode reports a data race in the following when the Thread Sanitizer is turned on.

file://me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Socket.swift: runtime: Threading Issues: Data race in SwiftPhoenixClient.Socket.ref.getter : Swift.UInt64 at 0x7b4800112b00

notice: Threading Issues: Location is a 328-byte heap object at 0x7b4800112b00

Read of size 8 by thread 73
#0  0x0000000107bb099b in Socket.ref.getter ()
#1  0x0000000107bbe3cc in Socket.makeRef() at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Socket.swift:557
#2  0x0000000107bc73a9 in Socket.sendHeartbeat() at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Socket.swift:749
#3  0x0000000107bc6f91 in closure #1 in Socket.resetHeartbeat() at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Socket.swift:723
#4  0x0000000107bc6fee in partial apply for closure #1 in Socket.resetHeartbeat() ()
#5  0x0000000107b8c058 in closure #1 in closure #1 in HeartbeatTimer.timer.getter at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/HeartbeatTimer.swift:36
#6  0x0000000107b8c58e in partial apply for closure #1 in closure #1 in HeartbeatTimer.timer.getter ()
#7  0x0000000107b8a544 in thunk for @escaping @callee_guaranteed () -> () ()
#8  0x000000010aa88462 in __tsan::dispatch_callback_wrap(void*) ()
#9  0x000000010ccc69c8 in _dispatch_client_callout ()
Write of size 8 by thread 1
#0  0x0000000107bb0a42 in Socket.ref.setter ()
#1  0x0000000107bbe48a in Socket.makeRef() at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Socket.swift:557
#2  0x0000000107baab3b in Push.startTimeout() at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Push.swift:223
#3  0x0000000107ba869c in Push.send() at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Push.swift:99
#4  0x0000000107b7cda8 in Channel.leave(timeout:) at me/Library/Developer/Xcode/DerivedData/wn-cccmnrlgdpilpfaaubrfwyvcgzhn/SourcePackages/checkouts/SwiftPhoenixClient/Sources/SwiftPhoenixClient/Channel.swift:511
#5  0x00000001075b18f7 in WAF.disconnect() at me/Projects/Clients/wn/wn-ios/wn/Network/WebsocketStreams/WAF.swift:806
#6  0x0000000107037277 in LiveRootViewController.viewWillDisappear(_:) at me/Projects/Clients/wn/wn-ios/wn/Main/Live/Root/LiveRootViewController.swift:214
#7  0x000000010703754a in @objc LiveRootViewController.viewWillDisappear(_:) ()
#8  0x00007fff23f68ddb in -[UIViewController _setViewAppearState:isAnimating:] ()
#9  0x0000000106b0c961 in static AppDelegate.$main() at me/Projects/Clients/wn/wn-ios/wn/AppDelegate.swift:12
#10 0x0000000106b0cb32 in main ()
dsrees commented 3 years ago

Thanks for reporting this find. Version 2.1.1 is out which fixes thread safety in HeartbeatTimer