]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 380269 - [PATCH] No multithreading in macOS Sierra (10.12)
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 13 Sep 2025 20:08:03 +0000 (22:08 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 13 Sep 2025 20:08:03 +0000 (22:08 +0200)
The patches were mostly applied, and now everything is.

coregrind/m_syswrap/syswrap-amd64-darwin.c
coregrind/m_syswrap/syswrap-darwin.c

index 6227352eee920c554601f503eb139f204eb90ee7..b2eb17f77e975bc66af3281d678feb560107ba9c 100644 (file)
@@ -476,15 +476,14 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem,
      /* For whatever reason, tst->os_state.pthread appear to have a
         constant offset of 96 on 10.7, but zero on 10.6 and 10.5.  No
         idea why. */
-#      if DARWIN_VERS <= DARWIN_10_6
+#      if DARWIN_VERS <= DARWIN_10_6 || DARWIN_VERS == DARWIN_10_13
        UWord magic_delta = 0;
 #      elif DARWIN_VERS == DARWIN_10_7 || DARWIN_VERS == DARWIN_10_8
        UWord magic_delta = 0x60;
 #      elif DARWIN_VERS == DARWIN_10_9 \
             || DARWIN_VERS == DARWIN_10_10 \
             || DARWIN_VERS == DARWIN_10_11 \
-            || DARWIN_VERS == DARWIN_10_12 \
-            || DARWIN_VERS == DARWIN_10_13
+            || DARWIN_VERS == DARWIN_10_12
        UWord magic_delta = 0xE0;
 #      else
 #        error "magic_delta: to be computed on new OS version"
@@ -528,6 +527,9 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem,
    vex->guest_R8  = reuse;
    vex->guest_R9  = 0;
    vex->guest_RSP = sp;
+#if DARWIN_VERS >= DARWIN_10_12
+   vex->guest_GS_CONST = self + pthread_tsd_offset;
+#endif
 
    stacksize = 512*1024;  // wq stacks are always DEFAULT_STACK_SIZE
    stack = VG_PGROUNDUP(sp) - stacksize;
index d6df8b9969643561c37629c3e5d5651073ddfbb4..2e1ba1da86dcf859d106babd83eab2c798dfe682 100644 (file)
@@ -2085,18 +2085,18 @@ PRE(bsdthread_register)
    pthread_starter = ARG1;
    wqthread_starter = ARG2;
    pthread_structsize = ARG3;
-   #if DARWIN_VERS >= DARWIN_10_12
-     typedef struct {
+#if DARWIN_VERS >= DARWIN_10_12
+    typedef struct {
        uint64_t version;
        uint64_t dispatch_queue_offset;
        uint64_t main_qos;
        uint32_t tsd_offset;
        uint32_t return_to_kernel_offset;
        uint32_t mach_thread_self_offset;
-     } __attribute__ ((packed)) _pthread_registration_data;
+    } __attribute__ ((packed)) _pthread_registration_data;
 
-     pthread_tsd_offset = ((_pthread_registration_data*) ARG4)->tsd_offset;
-   #endif
+    pthread_tsd_offset = ((_pthread_registration_data*) ARG4)->tsd_offset;
+#endif
    ARG1 = (Word)&pthread_hijack_asm;
    ARG2 = (Word)&wqthread_hijack_asm;
 }
@@ -2142,6 +2142,7 @@ PRE(workq_ops)
       // GrP fixme need anything here?
       // GrP fixme may block?
       break;
+   case VKI_WQOPS_THREAD_KEVENT_RETURN:
    case VKI_WQOPS_THREAD_RETURN: {
       // The interesting case. The kernel will do one of two things:
       // 1. Return normally. We continue; libc proceeds to stop the thread.
@@ -2171,10 +2172,6 @@ PRE(workq_ops)
       // JRS uh, looks like it queues up a bunch of threads, or some such?
       *flags |= SfMayBlock; // the kernel sources take a spinlock, so play safe
       break;
-   case VKI_WQOPS_THREAD_KEVENT_RETURN:
-      // RK fixme need anything here?
-      // perhaps similar to VKI_WQOPS_THREAD_RETURN above?
-      break;
    case VKI_WQOPS_SET_EVENT_MANAGER_PRIORITY:
       // RK fixme this just sets scheduling priorities - don't think we need
       // to do anything here
@@ -10487,6 +10484,7 @@ PRE(openat_nocancel)
    /* Otherwise handle normally */
    *flags |= SfMayBlock;
 }
+
 POST(openat_nocancel)
 {
    vg_assert(SUCCESS);