Repository navigation
Description
This is an audit of jemalloc using GPT 5.4. A similar audit in mimalloc turned up quite a few low severity bugs with some false positives.
List of unacknowledged bugs
Unacknowledged Bugs
Medium
1. SEC shard count accepts values the implementation cannot represent
The HPA SEC shard-count setting accepts any size_t, but shard selection and cached shard identifiers use uint8_t, and SEC metadata sizing multiplies the shard count without overflow checks.
Steps to reproduce
- Enable HPA SEC support and configure the shard count above
255, or to a value near integer-overflow limits. - Exercise SEC-backed allocation and deallocation paths across multiple threads.
- Observe wrapped shard identifiers for moderate values, or undersized SEC metadata arrays for extreme values.
Relevant source locations and functions
include/jemalloc/internal/sec_opts.h:13-20include/jemalloc/internal/tsd_internals.h:81,102src/conf.c:945-947src/sec.c:22-52sec_initsrc/sec.c:56-83sec_shard_picksrc/sec.c:85-90sec_bin_picksrc/sec.c:110-149sec_multishard_trylock_allocsrc/sec.c:212-237sec_multishard_trylock_dalloc
Expected impact
Moderate misconfiguration can silently break sharding, and extreme values can underallocate SEC metadata and lead to out-of-bounds access or crashes.
2. Generic TSD recursion guard can return an uninitialized wrapper during reentrant initialization
The generic TSD recursion guard adds a stack record to its recursion list before storing the wrapper pointer in that record. Same-thread reentry during that window can read an uninitialized pointer and treat it as a valid TSD wrapper.
Steps to reproduce
- Use a build that takes the generic TSD path.
- Trigger first-time TSD initialization.
- Cause same-thread reentry before the wrapper pointer is stored in the recursion block.
Relevant source locations and functions
include/jemalloc/internal/tsd_generic.h:78-100tsd_wrapper_getinclude/jemalloc/internal/tsd_generic.h:165-173tsd_getsrc/tsd.c:524-541tsd_init_check_recursion
Expected impact
Rare reentrant initialization can crash the allocator early in thread startup or corrupt internal allocator state.
3. b0_alloc_tcache_stack() reinserts edata_avail without base->mtx
b0_alloc_tcache_stack() removes an edata_t from base->edata_avail under the base mutex, but one failure path reinserts it without taking that same lock.
Steps to reproduce
- Trigger the path where
base_alloc_base_edata()succeeds but the later metadata allocation fails. - Run another thread that also allocates or frees base metadata at the same time.
- Observe the unlocked reinsertion race with other
edata_availmutations.
Relevant source locations and functions
src/base.c:280-295base_alloc_base_edatasrc/base.c:297-305base_extent_bump_alloc_postsrc/base.c:653-676b0_alloc_tcache_stack
Expected impact
Concurrent failure handling can corrupt base-allocator metadata and destabilize future allocator operations.
Low
4. Logging buffer append logic can write past the end of the stack buffer
log_impl_varargs() treats malloc_snprintf() and malloc_vsnprintf() return values as bounded append lengths. Once truncation happens, the computed write offset can move past the fixed log buffer and the next append writes out of bounds.
Steps to reproduce
- Reach a logging path that calls
log_impl_varargs(). - Pass a log name or formatted payload long enough to exceed the fixed log buffer.
- Let a follow-up append or newline write use the oversized offset.
Relevant source locations and functions
include/jemalloc/internal/log.h:91-105log_impl_varargssrc/malloc_io.c:693-703malloc_vsnprintf,malloc_snprintf
Expected impact
Stack out-of-bounds write in the logging path, usually ending in a crash or corrupted diagnostic output.
5. Bootstrap calloc can underallocate after multiplication overflow
bootstrap_calloc() multiplies the element count and element size without overflow checking. A wrapped product can produce a too-small allocation instead of failing.
Steps to reproduce
- Reach a bootstrap path that uses
bootstrap_calloc(). - Pass values whose product wraps but does not become zero.
- Use the returned allocation as if it covered the full requested element count.
Relevant source locations and functions
src/jemalloc.c:373-382bootstrap_calloc
Expected impact
Underallocation on bootstrap-only paths can lead to out-of-bounds access if the caller trusts the logical allocation size.
6. Explicit tcache IDs are dereferenced before table and index validation
Explicit tcache lookups dereference the tcaches table before verifying that the table exists or that the requested index is valid.
Steps to reproduce
- Use an explicit tcache ID before any explicit tcache has been created, or supply an invalid large tcache ID through the control interface.
- Reach the lookup, flush, or destroy path for that ID.
- Observe a null dereference or out-of-bounds table access before the invalid-ID check rejects the request.
Relevant source locations and functions
include/jemalloc/internal/tcache_inlines.h:229-239tcaches_getinclude/jemalloc/internal/jemalloc_internal_inlines_c.h:389-416tcache_get_from_indinclude/jemalloc/internal/jemalloc_internal_types.h:51-64src/tcache.c:1385-1406tcaches_flush,tcaches_destroysrc/ctl.c:2615-2639tcache_flush_ctl,tcache_destroy_ctl
Expected impact
Malformed or premature explicit tcache use can crash the process and may permit out-of-bounds in-process memory access through control paths.
7. Profiling log node allocation failures can turn into null dereferences
Several profiling log paths allocate bookkeeping nodes with iallocztm() and dereference the result immediately, without checking for allocation failure.
Steps to reproduce
- Enable profiling log support.
- Force internal allocation failure while the profiler is trying to create a new log node.
- Trigger a sampled allocation, sampled free, new thread log record, or new backtrace log record.
Relevant source locations and functions
src/prof_log.c:123-164prof_log_bt_indexsrc/prof_log.c:166-201prof_log_thr_indexsrc/prof_log.c:241-275prof_try_log
Expected impact
Memory pressure in profiling log mode can turn allocator bookkeeping failure into an immediate process crash.
8. Empty-batch mpsc_queue_push_batch() dereferences a null first element
The batched push helper assumes the source list is non-empty, but the API does not document that precondition. Passing an empty list yields a null first pointer that is dereferenced immediately.
Steps to reproduce
- Instantiate an MPSC queue and an empty source list.
- Call the generated batch-push helper with the empty list.
- Observe the first list element dereference even though the batch is empty.
Relevant source locations and functions
include/jemalloc/internal/mpsc_queue.h:61-82push_batchmacro expansioninclude/jemalloc/internal/ql.h:44,74-75
Expected impact
Immediate crash on an empty batch push.
9. Pairing-heap enumeration can crash on an empty heap in release builds
Pairing-heap enumeration always queues the root pointer, even when the heap is empty. In release builds that leads to a null dereference during the first enumeration step.
Steps to reproduce
- Prepare enumeration for an empty pairing heap.
- Advance the enumeration.
- Observe traversal dereference the queued null root pointer.
Relevant source locations and functions
include/jemalloc/internal/ph.h:460-474ph_enumerate_prepareinclude/jemalloc/internal/ph.h:477-499ph_enumerate_next
Expected impact
Release builds can crash when a caller enumerates an empty pairing heap.
10. MADV_DONTNEED self-test continues after mmap() failure and dereferences MAP_FAILED
The MADV_DONTNEED zeroing self-test logs mmap() failure, but if abort-on-error is not enabled it still proceeds to touch and unmap the failed address.
Steps to reproduce
- Reach the page-boot self-test path that probes
MADV_DONTNEEDbehavior. - Make the temporary mapping fail.
- Let execution continue instead of aborting immediately.
Relevant source locations and functions
src/pages.c:68-105madvise_MADV_DONTNEED_zeroes_pagessrc/pages.c:884-888pages_boot
Expected impact
Allocator initialization can crash on a failed temporary mapping.
11. Frame-pointer unwinding can read past the validated stack range
The frame-pointer backtrace path checks only that the frame pointer itself lies inside the recorded stack range, then reads two machine words from it without confirming that the full frame record also fits inside the range.
Steps to reproduce
- Use a build that takes the frame-pointer profiling unwinder path.
- Trigger a sampled allocation with a corrupted or boundary-adjacent frame chain.
- Let unwinding reach a frame pointer close to the top of the validated stack range.
Relevant source locations and functions
src/prof_sys.c:130-202prof_backtrace_implsrc/prof_sys.c:165-185prof_backtrace_impl
Expected impact
Profiling backtrace capture can perform an out-of-bounds stack read and crash.
12. malloc_vsnprintf() can read past short strings when %.*s precision is large
When formatting %s with an explicit precision, malloc_vsnprintf() copies exactly the precision length instead of clamping to the actual string length.
Steps to reproduce
- Format a short NUL-terminated string with
%.*s. - Supply a precision larger than the string length.
- Let the formatter copy the requested precision bytes from the short source buffer.
Relevant source locations and functions
src/malloc_io.c:374-381APPEND_Ssrc/malloc_io.c:662-668malloc_vsnprintf
Expected impact
Out-of-bounds read, potentially leaking adjacent bytes into formatted output or crashing near an unmapped boundary.
13. malloc_strtoumax() has undefined behavior on large negative boundary values
The negative-number path casts the parsed unsigned magnitude to intmax_t and negates it. Boundary values can make that cast implementation-defined and the negation undefined.
Steps to reproduce
- Parse a large negative value at or beyond the signed minimum boundary.
- Reach the negative-result conversion path.
- Observe undefined behavior or inconsistent result handling around the signed boundary.
Relevant source locations and functions
src/malloc_io.c:117-245malloc_strtoumax
Expected impact
Signed-boundary parsing can produce undefined behavior and inconsistent numeric results.
14. Signed formatting of INTMAX_MIN can trigger undefined behavior
The integer formatting helper negates negative values directly. Negating INTMAX_MIN is undefined because the positive value is not representable.
Steps to reproduce
- Format the minimum signed integer value through the signed decimal formatting path.
- Reach the helper that flips the sign before decimal conversion.
- Observe undefined behavior on the negation.
Relevant source locations and functions
src/malloc_io.c:309-336d2ssrc/malloc_io.c:592-616malloc_vsnprintf
Expected impact
Boundary-value formatting can trigger undefined behavior, sanitizer failures, or wrong output.
15. arena->last_thd is a cross-thread data race in arena selection
The per-arena last_thd heuristic is a plain pointer that is read and written on the arena-selection fast path without atomics or locking.
Steps to reproduce
- Enable per-CPU arena mode.
- Run multiple threads that share an auto arena and allocate concurrently.
- Observe simultaneous reads and writes of
last_thdin the arena-choose fast path.
Relevant source locations and functions
include/jemalloc/internal/arena_structs.h:41-46include/jemalloc/internal/jemalloc_internal_inlines_b.h:74-84arena_choose_implsrc/arena.c:1795arena initialization path
Expected impact
The race can misroute the arena-selection heuristic and introduces undefined behavior on a hot path.
16. Huge-arena initialization ignores mutex creation failure
Huge-arena setup initializes huge_arena_pac_thp.lock but does not check whether mutex creation succeeded before later using that mutex.
Steps to reproduce
- Enable the huge-arena THP path.
- Force mutex initialization for
huge_arena_pac_thp.lockto fail during setup. - Trigger an oversized huge-arena allocation that later takes the lock.
Relevant source locations and functions
src/arena.c:1960-1973arena_init_hugesrc/extent.c:673-699extent_handle_huge_arena_thpsrc/extent.c:824-830extent_alloc_wrapper_hardsrc/mutex.c:141-177malloc_mutex_init
Expected impact
Rare initialization failure can leave the allocator using an uninitialized mutex and crashing later in oversized allocation paths.
17. Partial commit verification checks uncommitted pages in debug builds
ehooks_commit() validates zero-filled memory for the whole extent even when the commit hook was asked to commit only a subrange.
Steps to reproduce
- Use a debug build with custom extent hooks.
- Implement a valid partial-commit hook that commits and zeroes only the requested subrange.
- Trigger a partial commit on an extent whose untouched pages still contain nonzero data.
Relevant source locations and functions
include/jemalloc/internal/ehooks.h:164-190ehooks_debug_zero_checkinclude/jemalloc/internal/ehooks.h:249-265ehooks_commit
Expected impact
Debug builds can abort even when a partial-commit hook obeys the documented contract.
18. Failed trailing split leaks the salvaged lead extent
On the two-step interior split path, if the first split succeeds and the second fails, the leading piece is deregistered but not returned to an extent cache or destroyed.
Steps to reproduce
- Recycle an extent that needs both a leading and trailing split.
- Let the first split succeed.
- Force the trailing split to fail through metadata exhaustion or split-hook failure.
Relevant source locations and functions
src/extent.c:372-389extent_deregistersrc/extent.c:488-536extent_split_interiorsrc/extent.c:557-600extent_recycle_split
Expected impact
Rare split-failure handling can leak retained virtual memory.
19. Sanitizer bump allocation can leak the previous current region after split failure
When the sanitizer bump allocator grows successfully and then fails while splitting the new region, it loses the old current region instead of restoring or destroying it.
Steps to reproduce
- Start with a non-empty sanitizer bump current region.
- Trigger a larger guarded allocation that grows the region successfully.
- Force the split of the new region to fail.
Relevant source locations and functions
src/san_bump.c:23-35san_bump_allocsrc/san_bump.c:43-66san_bump_allocsrc/san_bump.c:87-103san_bump_grow_lockedsrc/extent.c:1305-1362extent_split_impl
Expected impact
Rare sanitizer allocation failure can leak retained address space.
20. pages_huge_impl() flips success and error in the memcntl() path
The memcntl() branch returns success in the place where the rest of the pages API uses true to mean error.
Steps to reproduce
- Use a platform that takes the
memcntl()huge-page path. - Trigger a hugify attempt that succeeds.
- Observe the caller treat the success result as an error.
Relevant source locations and functions
src/pages.c:527-539pages_huge_implsrc/hpa_hooks.c:47-67hpa_hooks_hugifysrc/hpa.c:547-566hpa_try_hugify
Expected impact
Huge-page advice can be misreported and misaccounted on affected platforms.
21. Time-query failures are ignored, and the Mach path can divide by zero
clock_gettime(), gettimeofday(), and mach_timebase_info() failures are ignored. That can leave timestamp structures uninitialized, and on Mach can produce a divide-by-zero when the timebase denominator is never populated.
Steps to reproduce
- Force one of the time queries used by
nstime_get()or the realtime helper to fail. - Trigger code that updates allocator timestamps or profiling timestamps.
- On Mach, allow the failed timebase query to leave a zero denominator.
Relevant source locations and functions
src/nstime.c:208-247nstime_getsrc/nstime.c:266-271nstime_get_realtimesrc/nstime.c:278-303nstime_prof_update_impl,nstime_update_impl
Expected impact
Broken timekeeping can distort profiling and scheduling behavior, and Mach builds can crash on divide by zero.
22. NetBSD background-thread affinity uses an empty CPU set
The NetBSD affinity helper allocates a CPU set but never inserts the target CPU before calling pthread_setaffinity_np().
Steps to reproduce
- Use NetBSD with background threads and per-CPU arena mode enabled.
- Start a background thread.
- Let the thread attempt to pin itself to its target CPU.
Relevant source locations and functions
src/background_thread.c:121-158set_current_thread_affinitysrc/background_thread.c:516-518background_thread_entry
Expected impact
Background threads can fail to pin correctly, degrading or breaking per-CPU behavior.
23. CPU-count helpers can feed uninitialized affinity masks to CPU_COUNT()
The CPU-count helpers ignore failures from affinity queries and then count bits in an uninitialized CPU set.
Steps to reproduce
- Force the affinity query used during CPU counting to fail.
- Trigger the code that computes CPU count or CPU-count determinism.
- Let
CPU_COUNT()consume the uninitialized mask contents.
Relevant source locations and functions
src/jemalloc.c:736-772malloc_ncpussrc/jemalloc.c:781-808malloc_cpu_count_is_deterministic
Expected impact
Initialization can use garbage CPU counts, leading to bad arena sizing or other wrong CPU-topology decisions.
24. Registering a new user thread-event handler leaves existing threads stale
Registering a user thread-event handler recalculates event thresholds only for the registering thread. Other live threads keep stale wait counters and thresholds until they later hit an unrelated recalculation point.
Steps to reproduce
- Start worker threads and let them enter a steady allocation or free workload.
- Register a new user thread-event handler from another thread.
- Observe the existing workers delay or miss the new handler compared with the registering thread.
Relevant source locations and functions
src/thread_event_registry.c:195-213te_recalculate_current_thread_datasrc/thread_event_registry.c:215-238te_register_user_handlersrc/thread_event.c:198-215te_init_waitssrc/thread_event.c:295-347te_update_alloc_events,te_update_dalloc_events
Expected impact
Thread-event delivery becomes inconsistent across already-running threads.
25. Recent-allocation dumping races concurrent deallocation updates
The recent-allocation dump path iterates dumped records after dropping the recent-allocation mutex, while the deallocation-reset path can still update fields inside those same records.
Steps to reproduce
- Enable recent-allocation tracking.
- Dump recent allocations from one thread.
- Free recently recorded sampled allocations concurrently from another thread.
Relevant source locations and functions
include/jemalloc/internal/prof_structs.h:210-220src/prof_recent.c:145-185recent-allocation accessorssrc/prof_recent.c:195-239prof_recent_alloc_resetsrc/prof_recent.c:487-531prof_recent_alloc_dump_nodesrc/prof_recent.c:536-582prof_recent_alloc_dump
Expected impact
Profiling diagnostics can observe torn record state, emit inconsistent output, or crash under unlucky races.
26. prof_log_stop() can leave profiling stuck in the dumping state
If profiling log shutdown cannot create its output file, it returns before restoring the global log state from dumping to stopped.
Steps to reproduce
- Start profiling log collection.
- Point the log output at an unwritable or invalid file path.
- Stop logging and let file creation fail.
Relevant source locations and functions
src/prof_log.c:448-460prof_log_startsrc/prof_log.c:621-654prof_log_stop
Expected impact
Profiling log control can wedge permanently for the lifetime of the process.
27. Long profile dump prefixes can truncate uniqueness suffixes and overwrite dumps
Automatically generated profile dump filenames reserve only PATH_MAX + 1 bytes total, even though the configurable prefix itself can consume the same budget. Long prefixes can therefore truncate the PID or sequence suffixes that make dump filenames unique.
Steps to reproduce
- Configure a profile dump prefix near the path-length limit.
- Trigger multiple automatic or explicit profile dumps.
- Observe later dumps reuse the same truncated filename.
Relevant source locations and functions
include/jemalloc/internal/prof_types.h:71-75src/prof_sys.c:678-690prof_dump_open_file_implsrc/prof_sys.c:917-954prof_dump_filenamesrc/prof_sys.c:957-969prof_get_default_filenamesrc/prof_sys.c:983-1005prof_prefix_set
Expected impact
Profile dumps can overwrite each other and silently lose diagnostic data.
28. Profiling thread-name validation passes negative char values to ctype APIs
The profiling thread-name setter passes plain char values directly to isgraph() and isblank(). On platforms with signed char, non-ASCII bytes become negative and invoke undefined behavior.
Steps to reproduce
- Use a platform where
charis signed. - Set a profiling thread name containing bytes above
0x7f. - Let the validation loop call the ctype predicates on those bytes.
Relevant source locations and functions
src/prof_data.c:453-460prof_thread_name_set_impl
Expected impact
Thread-name validation can behave unpredictably or crash on affected libc implementations.
29. Shared fallback state in buf_writer_pipe() is unsynchronized across threads
The OOM fallback path in buf_writer_pipe() uses one static buffer and one static writer object for all callers.
Steps to reproduce
- Force buffered writer initialization to fall back to the static backup path.
- Call
buf_writer_pipe()concurrently from two threads. - Use different callbacks or callback contexts in the two callers.
Relevant source locations and functions
src/buf_writer.c:41-68buf_writer_initsrc/buf_writer.c:115-145buf_writer_pipe
Expected impact
Concurrent fallback logging can race, corrupt output, or send data through the wrong callback state.
30. Background-thread control paths can report failure after leaving global state changed
The background_thread and max_background_threads control handlers flip the global enabled-state flag before calling fallible enable or disable helpers, and do not reliably roll that flag back on failure.
Steps to reproduce
- Trigger a background-thread enable, disable, or resize operation through the control interface.
- Force the underlying thread creation or shutdown helper to fail.
- Read the background-thread state after the control call reports failure.
Relevant source locations and functions
include/jemalloc/internal/background_thread_inlines.h:20-23background_thread_enabled_setsrc/ctl.c:2012-2059background_thread_ctlsrc/ctl.c:2063-2117max_background_threads_ctlsrc/background_thread.c:539-597background_thread_create_lockedsrc/background_thread.c:613-680background_threads_enable,background_threads_disable
Expected impact
Control-plane state can become misleading or internally inconsistent after a failed background-thread operation.
31. Prefix-based config parsing accepts malformed keys and enum values
Several configuration branches accept prefix matches instead of exact matches for option names and enumerated values.
Steps to reproduce
- Provide configuration input with truncated or extended prefixes for one of the affected options.
- Initialize jemalloc or reload the configuration path.
- Observe the malformed token accepted as if it were a valid key or value.
Relevant source locations and functions
src/conf.c:469-470CONF_MATCHsrc/conf.c:569-585malloc_conf_init_helpersrc/conf.c:588-610malloc_conf_init_helpersrc/conf.c:813-835malloc_conf_init_helpersrc/conf.c:910-927malloc_conf_init_helpersrc/conf.c:1061-1081malloc_conf_init_helper
Expected impact
Malformed configuration can silently change allocator behavior instead of being rejected.
32. ctl_lookup() accepts partially numeric path components as valid indexes
Indexed control-path elements are parsed as numbers without verifying that the entire path component was numeric.
Steps to reproduce
- Call a control API with a path component that begins with digits but also contains trailing junk.
- Reach an indexed control node.
- Observe the partially numeric component resolve as a valid index.
Relevant source locations and functions
src/ctl.c:1491-1547ctl_lookup
Expected impact
Malformed control names can target the wrong indexed node instead of failing cleanly.
33. JSON emission does not escape keys or string values
The JSON emitter wraps keys and string values in quotes but does not escape embedded quotes, backslashes, or control characters.
Steps to reproduce
- Supply runtime state that contributes a string containing a quote, backslash, or newline to JSON output.
- Trigger stats, recent-allocation, or profiler JSON emission.
- Inspect the generated JSON.
Relevant source locations and functions
include/jemalloc/internal/emitter.h:121-149emitter_emit_strinclude/jemalloc/internal/emitter.h:283-289emitter_json_keysrc/stats.c:1185-1200,src/stats.c:1520-1537,src/stats.c:1613-1630src/prof_recent.c:500-519src/prof_log.c:502-505,src/prof_log.c:593-601
Expected impact
Downstream tooling can receive invalid JSON or attacker-controlled JSON structure in emitted reports.
34. Retained-growth preparation rejects the exact maximum legal size class
The retained-growth helper rejects a grow size exactly equal to SC_LARGE_MAXCLASS, even though that size class is otherwise legal and used as the configured upper limit.
Steps to reproduce
- Reach retained growth near the maximum large size class.
- Make the first acceptable grow size exactly equal to the configured maximum class.
- Observe the helper reject it instead of selecting it.
Relevant source locations and functions
include/jemalloc/internal/exp_grow.h:23-37exp_grow_size_preparesrc/exp_grow.c:5-13exp_grow_initsrc/extent.c:708-728extent_grow_retained
Expected impact
Boundary-case retained-growth can fail or fragment unexpectedly at the largest supported size.
35. HPA retained-page stats can underflow because related fields are read without a single snapshot
HPA retained-page reporting computes total - active - dirty from separate stats reads that are not tied to one consistent snapshot.
Steps to reproduce
- Run HPA activity that changes page-slab counts while stats are being refreshed.
- Print allocator stats repeatedly.
- Let the retained-page formula mix fields from different snapshots.
Relevant source locations and functions
src/stats.c:852-859stats_arena_hpa_shard_counters_printsrc/stats.c:960-967,src/stats.c:1003-1010,src/stats.c:1068-1075stats_arena_hpa_shard_slabs_printsrc/ctl.c:1899-1917stats readssrc/ctl.c:4053-4066HPA stats exposure
Expected impact
Printed retained-page counts can wrap to large bogus values and mislead diagnostics.
36. KQD expands through an undefined macro
KQD expands through QI, but the header defines QD and does not define QI.
Steps to reproduce
- Use the
KQDmacro in a translation unit. - Compile the file.
- Observe preprocessing or compilation fail because the expansion chain is broken.
Relevant source locations and functions
include/jemalloc/internal/jemalloc_internal_macros.h:28KQD
Expected impact
Any path that relies on KQD will fail to build.
37. Hash block readers perform typed reads from arbitrary byte buffers
The hash helpers accept arbitrary byte buffers but cast aligned inputs to uint32_t * or uint64_t * and dereference them directly, which can violate strict-aliasing or effective-type rules.
Steps to reproduce
- Hash an aligned buffer whose declared type is not
uint32_t[]oruint64_t[]. - Compile with aggressive optimization and strict aliasing enabled.
- Let the aligned fast path perform typed block reads from the byte buffer.
Relevant source locations and functions
include/jemalloc/internal/hash.h:26-48hash_get_block_32,hash_get_block_64include/jemalloc/internal/hash.h:85-89hash_x86_32include/jemalloc/internal/hash.h:148-156hash_x86_128include/jemalloc/internal/hash.h:312-317hash_x64_128include/jemalloc/internal/hash.h:422-434hash
Expected impact
Stricter toolchains can miscompile hashing paths or produce incorrect hash results.
38. Decay smoothstep arithmetic can overflow on very large page backlogs
Several decay calculations multiply page counts by fixed-point smoothstep weights and accumulate the results in uint64_t without overflow checks.
Steps to reproduce
- Populate decay state with very large synthetic or real page counts.
- Trigger backlog-limit or purge-estimation calculations.
- Let the weighted products and sums exceed
uint64_t.
Relevant source locations and functions
include/jemalloc/internal/smoothstep.h:27-30,include/jemalloc/internal/smoothstep.h:130,include/jemalloc/internal/smoothstep.h:230src/decay.c:97-109decay_backlog_npages_limitsrc/decay.c:159-173decay_npages_purge_insrc/decay.c:229-239decay_npurge_after_interval
Expected impact
Very large heaps can drive wrapped purge calculations and distort decay behavior.
Activity
Zoxc commentedon Apr 21, 2026
Just for reference, here's a list of bugs that was deemed acknowledged by the source code.
List of acknowledged bugs
Acknowledged Bugs
Medium
39. Experimental hook removal trusts opaque handles in release builds
The experimental hook-removal path accepts an opaque handle, but in non-debug builds it does not validate that the handle actually points into the internal hook table before using it.
Steps to reproduce
Relevant source locations and functions
include/jemalloc/internal/hook.h:143-150include/jemalloc/internal/seq.h:24-55src/hook.c:59-85hook_remove,hook_remove_lockedsrc/ctl.c:4237-4247experimental_hooks_remove_ctlExpected impact
Forged experimental hook handles can crash the process or corrupt memory in-process.
40. MSVC
stdboolcompatibility changes_Boolsemantics and ABIThe non-clang MSVC compatibility header maps
_Boolandboolto WindowsBOOL, which changes C99 boolean size, normalization rules, layout, and callback ABI.Steps to reproduce
boolvalues._Boolexpectations.Relevant source locations and functions
include/msvc_compat/C99/stdbool.h:6-17include/jemalloc/jemalloc_typedefs.h.in:9-80Expected impact
MSVC builds can suffer ABI and layout mismatches in public and internal interfaces that rely on C99 boolean behavior.
Low
41.
tsd_state_get()reads the first byte of an atomic state objectInstead of using an atomic load,
tsd_state_get()reads the first byte of the atomic state object directly. That is endian-sensitive for wider fallback atomics and races with atomic writers.Steps to reproduce
Relevant source locations and functions
include/jemalloc/internal/tsd_internals.h:212-222include/jemalloc/internal/tsd_internals.h:245-254tsd_state_getExpected impact
TSD state checks can race or observe the wrong state value on fallback configurations.
42. Large non-power-of-two PRNG ranges can trigger undefined shifts
The bounded-range PRNG helpers call
pow2_ceil_*()without rejecting non-power-of-two ranges near the top of the integer domain. That can trigger full-width bit shifts in release builds.Steps to reproduce
pow2_ceil_*()path.Relevant source locations and functions
include/jemalloc/internal/prng.h:103-167prng_range_u32,prng_range_u64,prng_range_zuinclude/jemalloc/internal/bit_util.h:362-395pow2_ceil_u32,pow2_ceil_u64,pow2_ceil_zuExpected impact
Oversized random-range requests can trigger undefined behavior and broken range generation.
43.
extent_record()can perform full-width shifts when the active-fit setting equals the word sizeThe
lg_extent_max_active_fitconfiguration accepts the machine bit width itself, butextent_record()later shifts by that value without guarding against a full-width shift.Steps to reproduce
lg_extent_max_active_fitto the machine word width.extent_record().Relevant source locations and functions
src/conf.c:808-811src/extent.c:1046-1052extent_recordsrc/eset.c:337-344eset_first_fitExpected impact
Accepted configuration can trigger undefined shift behavior in extent coalescing decisions.
44. Length-delimited multi-setting parsing is not actually bounded by the provided slice
multi_setting_parse_next()accepts a pointer and a remaining length, but it still calls unbounded numeric parsing and can inspect bytes beyond the logical slice boundary.Steps to reproduce
Relevant source locations and functions
include/jemalloc/internal/util.h:149-155src/util.c:8-45multi_setting_parse_nextsrc/conf.c:633-654,src/conf.c:959-985src/tcache.c:1133-1165src/ctl.c:2372-2384Expected impact
The parser can depend on adjacent bytes outside the declared slice and future callers could make the over-read more dangerous.
45. Setting an arena oversize threshold of zero routes all auto allocations to the huge arena
The arena type definition says an oversize threshold of zero disables huge-arena routing, but the actual routing check treats zero as “everything is oversize”.
Steps to reproduce
Relevant source locations and functions
include/jemalloc/internal/arena_types.h:41-43include/jemalloc/internal/arena_inlines_b.h:30-52arena_choose_maybe_hugesrc/ctl.c:2925-2950arena_i_oversize_threshold_ctlExpected impact
All auto allocations for that arena can be misrouted to the huge arena, causing correctness and performance regressions.
46.
retain_grow_limitacceptsSIZE_MAXand can reachsz_psz2ind(0)The retain-grow-limit setter computes
limit + 1before validating the new limit.SIZE_MAXwraps to zero and violates the preconditions of the page-size indexing helper.Steps to reproduce
SIZE_MAXthrough the control interface.Relevant source locations and functions
include/jemalloc/internal/sz.h:63-65sz_psz2indsrc/pac.c:392-401pac_retain_grow_limit_get_setsrc/ctl.c:3067-3089arena_i_retain_grow_limit_ctlExpected impact
Debug builds can assert, and release builds can apply undefined retain-growth configuration behavior.
47. Background-thread creation can hide signal-mask restoration failure
Background-thread creation returns only the thread-creation result, even if restoring the creator thread's original signal mask fails afterward.
Steps to reproduce
Relevant source locations and functions
src/background_thread.c:337-369background_thread_create_signals_maskedsrc/background_thread.c:398-417,src/background_thread.c:574-597Expected impact
The creator thread can keep the wrong signal mask even though background-thread creation is reported as successful.
48. Profiling fast paths read plain global flags without synchronization
The fast profiling getters read plain global
boolflags without atomics or the setter mutexes, while the setters write those same flags under locks.Steps to reproduce
Relevant source locations and functions
include/jemalloc/internal/prof_externs.h:42-46include/jemalloc/internal/prof_inlines.h:24-42prof_active_get_unlocked,prof_gdump_get_unlockedsrc/prof.c:478-500prof_active_get,prof_active_setsrc/prof.c:572-590prof_gdump_get,prof_gdump_setExpected impact
Profiling state can race, leading to stale or inconsistent behavior under the C memory model.
49. Windows error propagation uses thread last-error instead of C
errnoOn Windows, the allocator's
set_errnoandget_errnowrappers use thread last-error APIs rather than the C runtime'serrno, even when the surrounding code expects POSIX-styleerrnobehavior.Steps to reproduce
errno.errnoand Windows thread last-error afterward.Relevant source locations and functions
include/jemalloc/internal/util.h:55-71set_errno,get_errnosrc/malloc_io.c:118-264malloc_strtoumaxsrc/util.c:8-47multi_setting_parse_nextsrc/conf.c:260-262,src/conf.c:493-496Expected impact
Windows callers can observe wrong error reporting and mis-handle allocator or parser failures.
NITIN9181 commentedon Jul 27, 2026
Hi! I'd like to help out by fixing the first medium-severity bug listed here: "SEC shard count accepts values the implementation cannot represent".
I'll put together a PR to validate nshards and prevent the integer overflow when sizing the SEC metadata. I'll link the PR here once it's ready for review!
Fix SEC shard count integer overflow (jemalloc#2892)
Fix SEC shard count integer overflow (#2892)
Fix SEC shard count integer overflow (jemalloc#2892)