Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Access readerSharing in a thread safe way
The field .readerSharing can be used from different theads at the same time. We define it as _Atomic to have atomic accesses to the field and fix a TSAN warning: ================== WARNING: ThreadSanitizer: data race (pid=63123) Write of size 4 at 0x5575884d8cb8 by thread T3: #0 EHStatusHandlerThread PCSC/src/eventhandler.c:449:41 (pcscd+0xd6f12) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) Previous write of size 4 at 0x5575884d8cb8 by thread T8: #0 SCardDisconnect PCSC/src/winscard.c:1034:39 (pcscd+0xe4779) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #1 ContextThread PCSC/src/winscard_svc.c:575:16 (pcscd+0xe6507) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) As if synchronized via sleep: #0 nanosleep <null> (pcscd+0x515ed) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #1 SYS_USleep PCSC/src/sys_unix.c:87:9 (pcscd+0xd6fca) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #2 EHStatusHandlerThread PCSC/src/eventhandler.c (pcscd+0xd6fca) #3 __tsan_thread_start_func <null> (pcscd+0x53d66) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) Location is global 'readerStates' of size 2944 at 0x5575884d8c30 (pcscd+0x1497cb8) Thread T3 (tid=63127, running) created by main thread at: #0 pthread_create <null> (pcscd+0x53dfd) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #1 ThreadCreate PCSC/src/utils.c:184:8 (pcscd+0xe3cab) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #2 EHSpawnEventHandler PCSC/src/eventhandler.c:233:7 (pcscd+0xd6840) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #3 RFAddReader PCSC/src/readerfactory.c:397:8 (pcscd+0xdb6dd) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #4 HPAddDevice PCSC/src/hotplug_libudev.c:512:8 (pcscd+0xe3409) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #5 HPScanUSB PCSC/src/hotplug_libudev.c:579:3 (pcscd+0xe2a1d) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #6 HPRegisterForHotplugEvents PCSC/src/hotplug_libudev.c:761:2 (pcscd+0xe2a1d) #7 main PCSC/src/pcscdaemon.c:768:7 (pcscd+0xd8717) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) Thread T8 (tid=63221, finished) created by main thread at: #0 pthread_create <null> (pcscd+0x53dfd) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #1 ThreadCreate PCSC/src/utils.c:184:8 (pcscd+0xe3cab) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #2 CreateContextThread PCSC/src/winscard_svc.c:256:7 (pcscd+0xd924e) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #3 SVCServiceRunLoop PCSC/src/pcscdaemon.c:133:9 (pcscd+0xd924e) #4 main PCSC/src/pcscdaemon.c:801:2 (pcscd+0xd8810) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) #5 main PCSC/src/pcscdaemon.c:801:2 (pcscd+0xd8810) (BuildId: b2f519c8807f458b6282d631fe17086d4f6da420) SUMMARY: ThreadSanitizer: data race PCSC/src/eventhandler.c:449:41 in EHStatusHandlerThread ==================
- Loading branch information