summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Clean up malloc_ncpus().Jason Evans2013-11-301-8/+1
| | | | | | | Clean up malloc_ncpus() by replacing incorrectly indented if..else branches with a ?: expression. Submitted by Igor Podlesny.
* Fix ALLOCM_ARENA(a) handling in rallocm().Jason Evans2013-11-261-1/+1
| | | | | | | Fix rallocm() to use the specified arena for allocation, not just deallocation. Clarify ALLOCM_ARENA(a) documentation.
* Fix a potential infinite loop during thread exit.Jason Evans2013-11-201-1/+1
| | | | | | | | | Fix malloc_tsd_dalloc() to bypass tcache when dallocating, so that there is no danger of causing tcache reincarnation during thread exit. Whether this infinite loop occurs depends on the pthreads TSD implementation; it is known to occur on Solaris. Submitted by Markus Eberspächer.
* Remove unnecessary zeroing in arena_palloc().Jason Evans2013-10-301-43/+73
|
* Fix whitespace.Jason Evans2013-10-281-1/+1
|
* Add support for LinuxThreads.Leonard Crestez2013-10-251-0/+34
| | | | | | | | | | | | | | | | | When using LinuxThreads pthread_setspecific triggers recursive allocation on all threads. Work around this by creating a global linked list of in-progress tsd initializations. This modifies the _tsd_get_wrapper macro-generated function. When it has to initialize an TSD object it will push the item to the linked list first. If this causes a recursive allocation then the _get_wrapper request is satisfied from the list. When pthread_setspecific returns the item is removed from the list. This effectively adds a very poor substitute for real TLS used only during pthread_setspecific allocation recursion. Signed-off-by: Crestez Dan Leonard <lcrestez@ixiacom.com>
* Delay pthread_atfork registering.Leonard Crestez2013-10-241-12/+18
| | | | | | This function causes recursive allocation on LinuxThreads. Signed-off-by: Crestez Dan Leonard <lcrestez@ixiacom.com>
* Fix a file descriptor leak in a prof_dump_maps() error path.Jason Evans2013-10-211-8/+19
| | | | Reported by Pat Lynch.
* Add a missing mutex unlock in malloc_init_hard() error path.Jason Evans2013-10-211-1/+3
| | | | | | | | Add a missing mutex unlock in a malloc_init_hard() error path (failed mutex initialization). In practice this bug was very unlikely to ever trigger, but if it did, application deadlock would likely result. Reported by Pat Lynch.
* Avoid (x < 0) comparison for unsigned x.Jason Evans2013-10-211-2/+3
| | | | | | | Avoid (min < 0) comparison for unsigned min in malloc_conf_init(). This bug had no practical consequences. Reported by Pat Lynch.
* Fix a data race for large allocation stats counters.Jason Evans2013-10-211-1/+4
| | | | Reported by Pat Lynch.
* Consistently use malloc_mutex_prefork().Jason Evans2013-10-213-5/+5
| | | | | Consistently use malloc_mutex_prefork() instead of malloc_mutex_lock() in all prefork functions.
* Prefer not_reached() over assert(false) where appropriate.Jason Evans2013-10-214-7/+6
|
* Fix a compiler warning.Jason Evans2013-10-201-1/+1
| | | | | | | Fix a compiler warning in chunk_record() that was due to reading node rather than xnode. In practice this did not cause any correctness issue, but dataflow analysis in some compilers cannot tell that node and xnode are always equal in cases that the read is reached.
* Fix a race condition in the "arenas.extend" mallctl.Jason Evans2013-10-201-36/+44
| | | | | | | | Fix a race condition in the "arenas.extend" mallctl that could lead to internal data structure corruption. The race could be hit if one thread called the "arenas.extend" mallctl while another thread concurrently triggered initialization of one of the lazily created arenas.
* Fix a Valgrind integration flaw.Jason Evans2013-10-201-5/+18
| | | | | | Fix a Valgrind integration flaw that caused Valgrind warnings about reads of uninitialized memory in internal zero-initialized data structures (relevant to tcache and prof code).
* Fix a Valgrind integration flaw.Jason Evans2013-10-201-7/+14
| | | | | Fix a Valgrind integration flaw that caused Valgrind warnings about reads of uninitialized memory in arena chunk headers.
* Fix inlining warning.Jason Evans2013-10-201-3/+3
| | | | | | | | | Add the JEMALLOC_ALWAYS_INLINE_C macro and use it for always-inlined functions declared in .c files. This fixes a function attribute inconsistency for debug builds that resulted in (harmless) compiler warnings about functions not being inlinable. Reported by Ricardo Nabinger Sanchez.
* Silence an unused variable warning.Jason Evans2013-10-201-1/+1
| | | | Reported by Ricardo Nabinger Sanchez.
* malloc_conf_init: revert errno value when readlink(2) fail.Alexandre Perrin2013-10-131-14/+14
|
* Fix another deadlock related to chunk_record().Jason Evans2013-04-231-8/+11
| | | | | | Fix chunk_record() to unlock chunks_mtx before deallocating a base node, in order to avoid potential deadlock. This fix addresses the second of two similar bugs.
* Fix deadlock related to chunk_record().Jason Evans2013-04-171-4/+11
| | | | | | | Fix chunk_record() to unlock chunks_mtx before deallocating a base node, in order to avoid potential deadlock. Reported by Tudor Bosman.
* Fix a prof-related locking order bug.Jason Evans2013-02-063-12/+22
| | | | | Fix a locking order bug that could cause deadlock during fork if heap profiling were enabled.
* Fix Valgrind integration.Jason Evans2013-02-014-30/+37
| | | | | Fix Valgrind integration to annotate all internally allocated memory in a way that keeps Valgrind happy about internal data structure access.
* Fix a chunk recycling bug.Jason Evans2013-02-011-0/+1
| | | | | | | | | | | Fix a chunk recycling bug that could cause the allocator to lose track of whether a chunk was zeroed. On FreeBSD, NetBSD, and OS X, it could cause corruption if allocating via sbrk(2) (unlikely unless running with the "dss:primary" option specified). This was completely harmless on Linux unless using mlockall(2) (and unlikely even then, unless the --disable-munmap configure option or the "dss:primary" option was specified). This regression was introduced in 3.1.0 by the mlockall(2)/madvise(2) interaction fix.
* Fix two quarantine bugs.Jason Evans2013-01-311-10/+19
| | | | | | | Internal reallocation of the quarantined object array leaked the old array. Reallocation failure for internal reallocation of the quarantined object array (very unlikely) resulted in memory corruption.
* Fix potential TLS-related memory corruption.Jason Evans2013-01-313-57/+43
| | | | | | | | | | Avoid writing to uninitialized TLS as a side effect of deallocation. Initializing TLS during deallocation is unsafe because it is possible that a thread never did any allocation, and that TLS has already been deallocated by the threads library, resulting in write-after-free corruption. These fixes affect prof_tdata and quarantine; all other uses of TLS are already safe, whether intentionally (as for tcache) or unintentionally (as for arenas).
* Revert opt_abort and opt_junk refactoring.Jason Evans2013-01-231-2/+14
| | | | | | | | Revert refactoring of opt_abort and opt_junk declarations. clang accepts the config_*-based declarations (and generates correct code), but gcc complains with: error: initializer element is not constant
* Use config_* instead of JEMALLOC_*.Jason Evans2013-01-222-14/+4
| | | | Convert a couple of stragglers from JEMALLOC_* to use config_*.
* Update hash from MurmurHash2 to MurmurHash3.Jason Evans2013-01-222-88/+21
| | | | | | Update hash from MurmurHash2 to MurmurHash3, primarily because the latter generates 128 bits in a single call for no extra cost, which simplifies integration with cuckoo hashing.
* Add and use JEMALLOC_ALWAYS_INLINE.Jason Evans2013-01-221-3/+3
| | | | | Add JEMALLOC_ALWAYS_INLINE and use it to guarantee that the entire fast paths of the primary allocation/deallocation functions are inlined.
* Tighten valgrind integration.Jason Evans2013-01-222-22/+29
| | | | | | | Tighten valgrind integration such that immediately after memory is validated or zeroed, valgrind is told to forget the memory's 'defined' state. The only place newly allocated memory should be left marked as 'defined' is in the public functions (e.g. calloc() and realloc()).
* Avoid validating freshly mapped memory.Jason Evans2013-01-221-17/+17
| | | | | | | | | | | | | | Move validation of supposedly zeroed pages from chunk_alloc() to chunk_recycle(). There is little point to validating newly mapped memory returned by chunk_alloc_mmap(), and memory that comes from sbrk() is explicitly zeroed, so there is little risk to assuming that chunk_alloc_dss() actually does the zeroing properly. This relaxation of validation can make a big difference to application startup time and overall system usage on platforms that use jemalloc as the system allocator (namely FreeBSD). Submitted by Ian Lepore <ian@FreeBSD.org>.
* Don't mangle errno with free(3) if utrace(2) failsGarrett Cooper2012-12-241-0/+2
| | | | | | | This ensures POLA on FreeBSD (at least) as free(3) is generally assumed to not fiddle around with errno. Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
* Add clipping support to lg_chunk option processing.Jason Evans2012-12-231-19/+23
| | | | | | | | | Modify processing of the lg_chunk option so that it clips an out-of-range input to the edge of the valid range. This makes it possible to request the minimum possible chunk size without intimate knowledge of allocator internals. Submitted by Ian Lepore (see FreeBSD PR bin/174641).
* Fix chunk_recycle() Valgrind integration.Jason Evans2012-12-121-3/+2
| | | | | | | | Fix chunk_recycyle() to unconditionally inform Valgrind that returned memory is undefined. This fixes Valgrind warnings that would result from a huge allocation being freed, then recycled for use as an arena chunk. The arena code would write metadata to the chunk header, and Valgrind would consider these invalid writes.
* Fix "arenas.extend" mallctl to return the number of arenas.Jason Evans2012-11-301-9/+11
| | | | Reported by Mike Hommey.
* Avoid arena_prof_accum()-related locking when possible.Jason Evans2012-11-133-35/+7
| | | | | | | Refactor arena_prof_accum() and its callers to avoid arena locking when prof_interval is 0 (as when profiling is disabled). Reported by Ben Maurer.
* Tweak chunk purge order according to fragmentation.Jason Evans2012-11-071-11/+34
| | | | | Tweak chunk purge order to purge unfragmented chunks from high to low memory. This facilitates dirty run reuse.
* Don't register jemalloc's zone allocator if something else already replaced ↵Mike Hommey2012-11-071-1/+11
| | | | the system default zone
* Purge unused dirty pages in a fragmentation-reducing order.Jason Evans2012-11-061-191/+307
| | | | | | | | | | | | | | | | Purge unused dirty pages in an order that first performs clean/dirty run defragmentation, in order to mitigate available run fragmentation. Remove the limitation that prevented purging unless at least one chunk worth of dirty pages had accumulated in an arena. This limitation was intended to avoid excessive purging for small applications, but the threshold was arbitrary, and the effect of questionable utility. Relax opt_lg_dirty_mult from 5 to 3. This compensates for increased likelihood of allocating clean runs, given the same ratio of clean:dirty runs, and reduces the potential for repeated purging in pathological large malloc/free loops that push the active:dirty page ratio just over the purge threshold.
* Fix deadlock in the arenas.purge mallctl.Jason Evans2012-11-041-26/+22
| | | | | Fix deadlock in the arenas.purge mallctl due to recursive mutex acquisition.
* Fix dss/mmap allocation precedence code.Jason Evans2012-10-171-26/+14
| | | | | Fix dss/mmap allocation precedence code to use recyclable mmap memory only after primary dss allocation fails.
* Add ctl_mutex proection to arena_i_dss_ctl().Jason Evans2012-10-151-0/+2
| | | | | Add ctl_mutex proection to arena_i_dss_ctl(), since ctl_stats.narenas is accessed.
* Add arena-specific and selective dss allocation.Jason Evans2012-10-139-189/+603
| | | | | | | | | | | | | | | | | | | Add the "arenas.extend" mallctl, so that it is possible to create new arenas that are outside the set that jemalloc automatically multiplexes threads onto. Add the ALLOCM_ARENA() flag for {,r,d}allocm(), so that it is possible to explicitly allocate from a particular arena. Add the "opt.dss" mallctl, which controls the default precedence of dss allocation relative to mmap allocation. Add the "arena.<i>.dss" mallctl, which makes it possible to set the default dss precedence on a per arena or global basis. Add the "arena.<i>.purge" mallctl, which obsoletes "arenas.purge". Add the "stats.arenas.<i>.dss" mallctl.
* mark _pthread_mutex_init_calloc_cb as public explicitlyJan Beich2012-10-101-1/+1
| | | | | | | Mozilla build hides everything by default using visibility pragma and unhides only explicitly listed headers. But this doesn't work on FreeBSD because _pthread_mutex_init_calloc_cb is neither documented nor exposed via any header.
* Make malloc_usable_size() implementation consistent with prototype.Jason Evans2012-10-091-1/+1
| | | | | Use JEMALLOC_USABLE_SIZE_CONST for the malloc_usable_size() implementation as well as the prototype, for consistency's sake.
* Fix fork(2)-related mutex acquisition order.Jason Evans2012-10-091-3/+3
| | | | | | Fix mutex acquisition order inversion for the chunks rtree and the base mutex. Chunks rtree acquisition was introduced by the previous commit, so this bug was short-lived.
* Fix fork(2)-related deadlocks.Jason Evans2012-10-095-3/+144
| | | | | | | | | | | | | | | | | Add a library constructor for jemalloc that initializes the allocator. This fixes a race that could occur if threads were created by the main thread prior to any memory allocation, followed by fork(2), and then memory allocation in the child process. Fix the prefork/postfork functions to acquire/release the ctl, prof, and rtree mutexes. This fixes various fork() child process deadlocks, but one possible deadlock remains (intentionally) unaddressed: prof backtracing can acquire runtime library mutexes, so deadlock is still possible if heap profiling is enabled during fork(). This deadlock is known to be a real issue in at least the case of libgcc-based backtracing. Reported by tfengjun.
* Fix mlockall()/madvise() interaction.Jason Evans2012-10-093-40/+44
| | | | | | | | mlockall(2) can cause purging via madvise(2) to fail. Fix purging code to check whether madvise() succeeded, and base zeroed page metadata on the result. Reported by Olivier Lecomte.