From 9153ec8464336c280f2a6e79ffa443104bbeb98c Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Sun, 18 Sep 2016 22:45:16 -0700 Subject: [PATCH] XQuartz: Don't respond to SIGALRM on the AppKit thread ================== WARNING: ThreadSanitizer: data race (pid=69627) Write of size 8 at 0x00010dae73f8 by main thread (mutexes: write M262): #0 SmartScheduleTimer utils.c:1245 (X11.bin+0x0001004b21f9) #1 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, bool, int, my_siginfo_t*, void*) :144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000279f6) #2 __CFRunLoopRun :77 (CoreFoundation+0x000000087e17) #3 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062) #4 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b) #5 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5) #6 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9) #7 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44) #8 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #9 start :29 (libdyld.dylib+0x000000005254) Previous read of size 8 at 0x00010dae73f8 by thread T7: [failed to restore the stack] Location is global 'SmartScheduleTime' at 0x00010dae73f8 (X11.bin+0x0001005b03f8) Mutex M262 (0x7d300000bd10) created at: #0 pthread_mutex_init :144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3) #1 __CFRunLoopCreate :77 (CoreFoundation+0x000000054e63) #2 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062) #3 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b) #4 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5) #5 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9) #6 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44) #7 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #8 start :29 (libdyld.dylib+0x000000005254) Thread T7 (tid=4051693, 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+0x0001000398dd) #2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039813) #3 X11ApplicationMain X11Application.m:1286 (X11.bin+0x00010001c804) #4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062) #5 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b) #6 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5) #7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9) #8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44) #9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #10 start :29 (libdyld.dylib+0x000000005254) SUMMARY: ThreadSanitizer: data race utils.c:1245 in SmartScheduleTimer ================== ================== WARNING: ThreadSanitizer: signal handler spoils errno (pid=69627) #0 SmartScheduleTimer utils.c:1244 (X11.bin+0x0001004b21a0) #1 __CFRunLoopRun :77 (CoreFoundation+0x000000087e17) #2 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a062) #3 server_main quartzStartup.c:127 (X11.bin+0x000100039b6b) #4 do_start_x11_server bundle-main.c:436 (X11.bin+0x0001000022c5) #5 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x0001000042a9) #6 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100004b44) #7 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #8 start :29 (libdyld.dylib+0x000000005254) SUMMARY: ThreadSanitizer: signal handler spoils errno utils.c:1244 in SmartScheduleTimer ================== Signed-off-by: Jeremy Huddleston Sequoia --- hw/xquartz/quartzStartup.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c index 4dc4dd630..bb92b6d3c 100644 --- a/hw/xquartz/quartzStartup.c +++ b/hw/xquartz/quartzStartup.c @@ -95,6 +95,15 @@ QuartzInitServer(int argc, char **argv, char **envp) if (!create_thread(server_thread, args)) { FatalError("can't create secondary thread\n"); } + + /* Block signals on the AppKit thread that the X11 expects to handle on its thread */ + sigset_t set; + sigemptyset(&set); + sigaddset(&set, SIGALRM); +#ifdef BUSFAULT + sigaddset(&set, SIGBUS); +#endif + pthread_sigmask(SIG_BLOCK, &set, NULL); } int