summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #59 from HarryWeppner/devJason Evans2014-03-291-1/+4
|\ | | | | FreeBSD memory (leak) profiling support
| * Consistently use debug lib(s) if presentHarald Weppner2014-03-281-8/+5
| | | | | | | | | | | | Fixes a situation where nm uses the debug lib but addr2line does not, which completely messes up the symbol lookup.
| * Enable profiling / leak detection in FreeBSDHarald Weppner2014-03-181-1/+7
| | | | | | | | | | * Assumes procfs is mounted at /proc, cf. <http://www.freebsd.org/doc/en/articles/linux-users/procfs.html>
* | Merge pull request #61 from mxw/huge-dss-precJason Evans2014-03-282-11/+17
|\ \ | | | | | | Use arena dss prec instead of default for huge allocs.
| * | Use arena dss prec instead of default for huge allocs.Max Wang2014-03-282-11/+17
| |/ | | | | | | | | Pass a dss_prec_t parameter to huge_{m,p,r}alloc instead of defaulting to the chunk dss prec.
* | Fix a crashing case where arena_chunk_init_hard returns NULL.Chris Pride2014-03-261-1/+4
|/ | | | | | | | | | | | | This happens when it fails to allocate a new chunk. Which arena_chunk_alloc then passes into arena_avail_insert without any checks. This then causes a crash when arena_avail_insert tries to check chunk->ndirty. This was introduced by the refactoring of arena_chunk_alloc which previously would have returned NULL immediately after calling chunk_alloc. This is now the return from arena_chunk_init_hard so we need to check that return, and not continue if it was NULL.
* Fix junk filling for mremap(2)-based huge reallocation.Jason Evans2014-02-251-0/+10
| | | | | | | If mremap(2) is used for huge reallocation, physical pages are mapped to new virtual addresses rather than data being copied to new pages. This bypasses the normal junk filling that would happen during allocation, so add junk filling that is specific to this case.
* Fix typoErwan Legrand2014-02-141-1/+0
|
* Test and fix malloc_printf("%%").Jason Evans2014-01-221-7/+6
|
* Fix unused variable warnings.Jason Evans2014-01-211-4/+2
|
* Add heap profiling tests.Jason Evans2014-01-171-13/+39
| | | | | | Fix a regression in prof_dump_ctx() due to an uninitized variable. This was caused by revision 4f37ef693e3d5903ce07dc0b61c0da320b35e3d9, so no releases are affected.
* Fix a variable prototype/definition mismatch.Jason Evans2014-01-171-2/+1
|
* Refactor prof_dump() to reduce contention.Jason Evans2014-01-161-172/+273
| | | | | | | | | | | | | | Refactor prof_dump() to use a two pass algorithm, and prof_leave() prior to the second pass. This avoids write(2) system calls while holding critical prof resources. Fix prof_dump() to close the dump file descriptor for all relevant error paths. Minimize the size of prof-related static buffers when prof is disabled. This saves roughly 65 KiB of application memory for non-prof builds. Refactor prof_ctx_init() out of prof_lookup_global().
* Refactor prof_lookup() by extracting prof_lookup_global().Jason Evans2014-01-151-82/+79
|
* Refactor overly large/complex functions.Jason Evans2014-01-151-383/+461
| | | | | | | Refactor overly large functions by breaking out helper functions. Refactor overly complex multi-purpose functions into separate more specific functions.
* Extract profiling code from [re]allocation functions.Jason Evans2014-01-123-367/+460
| | | | | | | | | | | | | | | | | | | Extract profiling code from malloc(), imemalign(), calloc(), realloc(), mallocx(), rallocx(), and xallocx(). This slightly reduces the amount of code compiled into the fast paths, but the primary benefit is the combinatorial complexity reduction. Simplify iralloc[t]() by creating a separate ixalloc() that handles the no-move cases. Further simplify [mrxn]allocx() (and by implication [mrn]allocm()) to make request size overflows due to size class and/or alignment constraints trigger undefined behavior (detected by debug-only assertions). Report ENOMEM rather than EINVAL if an OOM occurs during heap profiling backtrace creation in imemalign(). This bug impacted posix_memalign() and aligned_alloc().
* Add junk/zero filling unit tests, and fix discovered bugs.Jason Evans2014-01-082-19/+92
| | | | | | Fix growing large reallocation to junk fill new space. Fix huge deallocation to junk fill when munmap is disabled.
* Add util unit tests, and fix discovered bugs.Jason Evans2014-01-071-28/+36
| | | | | | | | | | | | | Add unit tests for pow2_ceil(), malloc_strtoumax(), and malloc_snprintf(). Fix numerous bugs in malloc_strotumax() error handling/reporting. These bugs could have caused application-visible issues for some seldom used (0X... and 0... prefixes) or malformed MALLOC_CONF or mallctl() argument strings, but otherwise they had no impact. Fix numerous bugs in malloc_snprintf(). These bugs were not exercised by existing malloc_*printf() calls, so they had no impact.
* Convert rtree from (void *) to (uint8_t) storage.Jason Evans2014-01-032-18/+27
| | | | | | | | | | | | | Reduce rtree memory usage by storing booleans (1 byte each) rather than pointers. The rtree code is only used to record whether jemalloc manages a chunk of memory, so there's no need to store pointers in the rtree. Increase rtree node size to 64 KiB in order to reduce tree depth from 13 to 3 on 64-bit systems. The conversion to more compact leaf nodes was enough by itself to make the rtree depth 1 on 32-bit systems; due to the fact that root nodes are smaller than the specified node size if possible, the node size change has no impact on 32-bit systems (assuming default chunk size).
* Add rtree unit tests.Jason Evans2014-01-032-4/+33
|
* Fix an uninitialized variable read in xallocx().Jason Evans2013-12-201-0/+3
|
* Fix a few mallctl() documentation errors.Jason Evans2013-12-201-121/+124
| | | | Normalize mallctl() order (code and documentation).
* Add quarantine unit tests.Jason Evans2013-12-172-14/+65
| | | | | | | | | Verify that freed regions are quarantined, and that redzone corruption is detected. Introduce a testing idiom for intercepting/replacing internal functions. In this case the replaced function is ordinarily a static function, but the idiom should work similarly for library-private functions.
* Don't junk-fill reallocations unless usize changes.Jason Evans2013-12-162-16/+3
| | | | | | | | | | | Don't junk fill reallocations for which the request size is less than the current usable size, but not enough smaller to cause a size class change. Unlike malloc()/calloc()/realloc(), *allocx() contractually treats the full usize as the allocation, so a caller can ask for zeroed memory via mallocx() and a series of rallocx() calls that all specify MALLOCX_ZERO, and be assured that all newly allocated bytes will be zeroed and made available to the application without danger of allocator mutation until the size class decreases enough to cause usize reduction.
* Optimize arena_prof_ctx_set().Jason Evans2013-12-161-43/+58
| | | | | | Refactor such that arena_prof_ctx_set() receives usize as an argument, and use it to determine whether to handle ptr as a small region, rather than reading the chunk page map.
* Implement the *allocx() API.Jason Evans2013-12-135-169/+301
| | | | | | | | | | | | | | | | | | | | | | | Implement the *allocx() API, which is a successor to the *allocm() API. The *allocx() functions are slightly simpler to use because they have fewer parameters, they directly return the results of primary interest, and mallocx()/rallocx() avoid the strict aliasing pitfall that allocm()/rallocx() share with posix_memalign(). The following code violates strict aliasing rules: foo_t *foo; allocm((void **)&foo, NULL, 42, 0); whereas the following is safe: foo_t *foo; void *p; allocm(&p, NULL, 42, 0); foo = (foo_t *)p; mallocx() does not have this problem: foo_t *foo = (foo_t *)mallocx(42, 0);
* Fix inline-related macro issues.Jason Evans2013-12-101-6/+6
| | | | | | | | | Add JEMALLOC_INLINE_C and use it instead of JEMALLOC_INLINE in .c files, so that the annotated functions are always static. Remove SFMT's inline-related macros and use jemalloc's instead, so that there's no danger of interactions with jemalloc's definitions that disable inlining for debug builds.
* Silence some unused variable warnings.Jason Evans2013-12-101-4/+4
|
* Normalize #define whitespace.Jason Evans2013-12-094-7/+7
| | | | Consistently use a tab rather than a space following #define.
* Refactor tests.Jason Evans2013-12-093-6/+6
| | | | | | | Refactor tests to use explicit testing assertions, rather than diff'ing test output. This makes the test code a bit shorter, more explicitly encodes testing intent, and makes test failure diagnosis more straightforward.
* Avoid deprecated sbrk(2) on OS X.Jason Evans2013-12-041-7/+8
| | | | | Avoid referencing sbrk(2) on OS X, because it is deprecated as of OS X 10.9 (Mavericks), and the compiler warns against using it.
* Remove unused variable.Jason Evans2013-12-021-1/+0
|
* 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.