Skip to content

Commit

Permalink
cgmemmgr,macos: add missing shared_map_lock initialization
Browse files Browse the repository at this point in the history
(cherry picked from commit 3661a08)
  • Loading branch information
vtjnash authored and KristofferC committed Dec 21, 2022
1 parent e8b6fdc commit 45df676
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cgmemmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ static size_t map_offset = 0;
// Hopefully no one will set a ulimit for this to be a problem...
static constexpr size_t map_size_inc_default = 128 * 1024 * 1024;
static size_t map_size = 0;
static jl_mutex_t shared_map_lock;
static struct _make_shared_map_lock {
uv_mutex_t mtx;
_make_shared_map_lock() {
uv_mutex_init(&mtx);
};
} shared_map_lock;

static size_t get_map_size_inc()
{
Expand Down Expand Up @@ -258,7 +263,7 @@ static void *alloc_shared_page(size_t size, size_t *id, bool exec)
*id = off;
size_t map_size_inc = get_map_size_inc();
if (__unlikely(off + size > map_size)) {
JL_LOCK_NOGC(&shared_map_lock);
uv_mutex_lock(&shared_map_lock.mtx);
size_t old_size = map_size;
while (off + size > map_size)
map_size += map_size_inc;
Expand All @@ -269,7 +274,7 @@ static void *alloc_shared_page(size_t size, size_t *id, bool exec)
abort();
}
}
JL_UNLOCK_NOGC(&shared_map_lock);
uv_mutex_unlock(&shared_map_lock.mtx);
}
return create_shared_map(size, off);
}
Expand Down

0 comments on commit 45df676

Please sign in to comment.