From daabb53092210bc0fc43bff063a11b99c7a39ccd Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Sat, 21 Nov 2026 00:21:06 +0000 Subject: [PATCH] fix(alloc): pass NULL pointers in jemalloc notify ctls --- src/core/alloc/je.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/alloc/je.rs b/src/core/alloc/je.rs index 1aeb5257e..867bdef51 100644 --- a/src/core/alloc/je.rs +++ b/src/core/alloc/je.rs @@ -390,7 +390,25 @@ where get(&key) } -fn notify(key: &Key) -> Result { xchg(key, ()) } +fn notify(key: &Key) -> Result { + // SAFETY: jemalloc notification ctls require `oldp`, `oldlenp`, and `newp` + // to be NULL and `newlen` to be 0 (otherwise `EPERM` is returned). + let ret = unsafe { + ffi::mallctlbymib( + key.as_ptr(), + key.len(), + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + 0, + ) + }; + if ret == 0 { + Ok(()) + } else { + Err(err!("mallctl: {}", std::io::Error::from_raw_os_error(ret))) + } +} fn set(key: &Key, val: T) -> Result where