From f72ff1f7ac784f3911fe2f8d746f62f7709f0edc Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Mon, 19 Sep 2016 09:34:50 -0700 Subject: [PATCH] XQuartz: Silence an expected TSan warning This code is safe. If the data race fails, the result is that we take the lock and recheck. ================== WARNING: ThreadSanitizer: data race (pid=31401) Read of size 1 at 0x00010f5d2500 by thread T11: #0 wait_for_mieq_init darwinEvents.c:102 (X11.bin+0x00010003155a) #1 -[X11Application(Private) sendX11NSEvent:] X11Application.m:1330 (X11.bin+0x00010001d652) #2 __28-[X11Application sendEvent:]_block_invoke X11Application.m:476 (X11.bin+0x00010001887f) #3 __tsan::invoke_and_release_block(void*) :144 (libclang_rt.tsan_osx_dynamic.dylib+0x00000005d97b) #4 _dispatch_client_callout :33 (libdispatch.dylib+0x0000000020ef) Previous write of size 1 at 0x00010f5d2500 by thread T8: [failed to restore the stack] Location is global 'mieqInitialized' at 0x00010f5d2500 (X11.bin+0x000100599500) Thread T11 (tid=4367138, running) created by thread T-1 [failed to restore the stack] Thread T8 (tid=4367130, running) created by main thread at: #0 pthread_create :144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490) #1 create_thread quartzStartup.c:78 (X11.bin+0x000100039d2d) #2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039b96) #3 X11ApplicationMain X11Application.m:1238 (X11.bin+0x00010001cd54) #4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a5b2) #5 server_main quartzStartup.c:136 (X11.bin+0x000100039fbb) #6 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002e25) #7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e09) #8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x0001000056a4) #9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #10 start :29 (libdyld.dylib+0x000000005254) SUMMARY: ThreadSanitizer: data race darwinEvents.c:102 in wait_for_mieq_init ================== Signed-off-by: Jeremy Huddleston Sequoia --- hw/xquartz/darwinEvents.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index a3b70f569..fd87e968b 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -96,6 +96,7 @@ static BOOL mieqInitialized; static pthread_mutex_t mieqInitializedMutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t mieqInitializedCond = PTHREAD_COND_INITIALIZER; +_X_NOTSAN extern inline void wait_for_mieq_init(void) { @@ -108,6 +109,7 @@ wait_for_mieq_init(void) } } +_X_NOTSAN static inline void signal_mieq_init(void) {