Loading...
--- libmalloc/libmalloc-283.100.6/src/nanov2_malloc.c
+++ libmalloc/libmalloc-374.40.6/src/nanov2_malloc.c
@@ -596,15 +596,15 @@
#if CONFIG_NANO_USES_HYPER_SHIFT
if (os_likely(nano_common_max_magazines_is_ncpu)) {
// Default case is max magazines == physical number of CPUs, which
- // must be > _os_cpu_number() >> hyper_shift, so the modulo
+ // must be > _malloc_cpu_number() >> hyper_shift, so the modulo
// operation is not required.
- return _os_cpu_number() >> hyper_shift;
+ return _malloc_cpu_number() >> hyper_shift;
}
#else // CONFIG_NANO_USES_HYPER_SHIFT
if (os_likely(nano_common_max_magazines_is_ncpu)) {
// Default case is max magazines == logical number of CPUs, which
- // must be > _os_cpu_number() so the modulo operation is not required.
- return _os_cpu_number();
+ // must be > _malloc_cpu_number() so the modulo operation is not required.
+ return _malloc_cpu_number();
}
#endif // CONFIG_NANO_USES_HYPER_SHIFT
@@ -614,7 +614,7 @@
#endif // CONFIG_NANO_USES_HYPER_SHIFT
if (os_likely(_os_cpu_number_override == -1)) {
- return (_os_cpu_number() >> shift) % nano_common_max_magazines;
+ return (_malloc_cpu_number() >> shift) % nano_common_max_magazines;
}
return (_os_cpu_number_override >> shift) % nano_common_max_magazines;
}
@@ -1334,7 +1334,7 @@
if (kr) {
return kr;
}
- boolean_t self_zone = (nanozonev2_t *)zone_address == nanozone;
+ boolean_t self_zone = mach_task_is_self(task) && (nanozonev2_t *)zone_address == nanozone;
memcpy(&zone_copy, nanozone, sizeof(zone_copy));
nanozone = &zone_copy;
nanov2_meta_index_t metablock_meta_index = nanov2_metablock_meta_index(nanozone);
@@ -1486,7 +1486,7 @@
static boolean_t
nanov2_check(nanozonev2_t *nanozone)
{
- // Does nothing, just like Nano V1.
+ // Does nothing
return 1;
}
@@ -1722,7 +1722,7 @@
static void
nanov2_log(malloc_zone_t *zone, void *log_address)
{
- // Does nothing, just like Nano V1.
+ // Does nothing
}
static void
@@ -2204,8 +2204,7 @@
ptr = nanov2_slot_in_block_ptr(blockp, size_class, slot);
}
- nanov2_free_slot_t *slotp =
- (nanov2_free_slot_t *)os_atomic_force_dependency_on(ptr,
+ nanov2_free_slot_t *slotp = os_atomic_inject_dependency(ptr,
(unsigned long)old_meta_view.bits);
if (from_free_list) {
// We grabbed the item from the free list. Check the free list canary
@@ -2214,7 +2213,7 @@
// write to it.
uintptr_t guard = os_atomic_load(&slotp->double_free_guard, relaxed);
if ((guard ^ nanozone->slot_freelist_cookie) != (uintptr_t)ptr) {
- malloc_zone_error(MALLOC_ABORT_ON_CORRUPTION, false,
+ malloc_zone_error(MALLOC_ABORT_ON_CORRUPTION, true,
"Heap corruption detected, free list is damaged at %p\n"
"*** Incorrect guard value: %lu\n", ptr, guard);
__builtin_unreachable();