From: Philippe Waroquiers Date: Fri, 5 Sep 2014 23:57:57 +0000 (+0000) Subject: Fix 338698 race condition between gdbsrv and vgdb on startup X-Git-Tag: svn/VALGRIND_3_10_0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dfb7a0433c5eea67d0a536f56bcde031a067bf8;p=thirdparty%2Fvalgrind.git Fix 338698 race condition between gdbsrv and vgdb on startup git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14475 --- diff --git a/NEWS b/NEWS index 24f79ab39d..e16456a182 100644 --- a/NEWS +++ b/NEWS @@ -309,6 +309,7 @@ where XXXXXX is the bug number as listed below. 338499 --sim-hints parsing broken due to wrong order in tokens 338615 suppress glibc 2.20 optimized strcmp implementation for ARMv7 338681 Unable to unwind through clone thread created on i386-linux +338698 race condition between gdbsrv and vgdb on startup 338703 helgrind on arm-linux gets false positives in dynamic loader n-i-bz Fix KVM_CREATE_IRQCHIP ioctl handling n-i-bz s390x: Fix memory corruption for multithreaded applications diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c index 6ee1f7e053..aa2cd4ae06 100644 --- a/coregrind/m_gdbserver/remote-utils.c +++ b/coregrind/m_gdbserver/remote-utils.c @@ -390,11 +390,6 @@ void remote_open (const HChar *name) VG_(unlink)(to_gdb); VG_(unlink)(shared_mem); - safe_mknod(from_gdb); - safe_mknod(to_gdb); - - pid_from_to_creator = pid; - o = VG_(open) (shared_mem, VKI_O_CREAT|VKI_O_RDWR, 0600); if (sr_isError (o)) { sr_perror(o, "cannot create shared_mem file %s\n", shared_mem); @@ -421,6 +416,15 @@ void remote_open (const HChar *name) } shared = (VgdbShared*) addr_shared; VG_(close) (shared_mem_fd); + + safe_mknod(to_gdb); + safe_mknod(from_gdb); + /* from_gdb is the last resource created: vgdb searches such FIFOs + to detect the presence of a valgrind process. + So, we better create this resource when all the rest needed by + vgdb is ready : the other FIFO and the shared memory. */ + + pid_from_to_creator = pid; } setup_remote_desc_for_reading ();