From 64a2434c9d6bc177df6f20ac42c0fd26fb2ba3b9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 31 Oct 2016 19:45:30 +0100 Subject: gsync: Fix assertion failure with MACH_LDEBUG vm_map_lock_read calls check_simple_locks(), so we need to lock hbp after taking the vm_map read lock. * kern/gsync.c (gsync_wait): Call vm_map_lock_read before locking &hbp->lock. (gsync_wake): Likewise. --- kern/gsync.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kern/gsync.c b/kern/gsync.c index 68b3d0b0..d0f609fb 100644 --- a/kern/gsync.c +++ b/kern/gsync.c @@ -191,14 +191,14 @@ kern_return_t gsync_wait (task_t task, vm_offset_t addr, if (unlikely (bucket < 0)) return (KERN_INVALID_ADDRESS); - struct gsync_hbucket *hbp = gsync_buckets + bucket; - simple_lock (&hbp->lock); - - /* Now test that the address is actually valid for the + /* Test that the address is actually valid for the * given task. Do so with the read-lock held in order * to prevent memory deallocations. */ vm_map_lock_read (task->map); + struct gsync_hbucket *hbp = gsync_buckets + bucket; + simple_lock (&hbp->lock); + if (unlikely (!valid_access_p (task->map, addr, flags))) { simple_unlock (&hbp->lock); @@ -285,9 +285,9 @@ kern_return_t gsync_wake (task_t task, kern_return_t ret = KERN_INVALID_ARGUMENT; + vm_map_lock_read (task->map); struct gsync_hbucket *hbp = gsync_buckets + bucket; simple_lock (&hbp->lock); - vm_map_lock_read (task->map); if (unlikely (!valid_access_p (task->map, addr, flags))) { -- cgit v1.2.3