otto
3eeb2e7bb1
stray tab
8 years ago
otto
2c67f40d2b
Beter implementation of chunk canaries: store size in chunk meta data
instead of chunk itself; does not change actual allocated size; ok tedu@
8 years ago
guenther
1a1f277cca
Delete casts to off_t and size_t that are implied by assignments
or prototypes. Ditto for some of the char* and void* casts too.
verified no change to instructions on ILP32 (i386) and LP64 (amd64)
ok natano@ abluhm@ deraadt@ millert@
8 years ago
otto
814803d97e
move page junking tp unmap(), right before we stick the region in the cache;
ok tedu@
8 years ago
otto
7f29e95497
Less lock contention by using more pools for mult-threaded programs.
tested by many (thanks!) ok tedu, guenther@
8 years ago
tedu
6c73827bf7
black magic for sparc page size can go
8 years ago
otto
8b9a47cd4e
wrterror() is fatal, delete dead code; ok tom@ natano@ tedu@
8 years ago
otto
48a1ebbb9c
J/j is a three valued option, document and fix code to actuall support that
with a little help from jmc@ for the man page bits
ok jca@ and a reluctant tedu@
8 years ago
otto
4e61a98ad4
adapt S option: add C, rm F (not relevant with 0 cache and disables
chunk rnd), rm P: is default
8 years ago
tb
071457b57b
Back out previous; otto saw a potential race that could lead to a
double unmap and I experienced a much more unstable firefox.
discussed with otto on icb
8 years ago
tedu
86a8b4eb22
defer munmap to after unlocking malloc. this can (unfortunately) be an
expensive syscall, and we don't want to tie up other threads. there's no
need to hold the lock, so defer it to afterwards.
from Michael McConville
ok deraadt
8 years ago
otto
6ff3199d0a
two times a define to an inline function, from Michael McConville; ok djm@
9 years ago
otto
dc2fbbc2b1
tweak MALLOC_STATS printing (switched off by default), prodded by
Michael McConville
9 years ago
otto
848e061151
redundant memset(3), from Michael McConville, ok armani@
9 years ago
mmcc
71aec69783
properly guard to macros
ok otto@
9 years ago
otto
32c6baecf9
small step towards multiple pools: move two globls into the struct dir_info
ok @stefan armani@
9 years ago
guenther
34213b2037
environ and __progname are not declared in a public header; declare them
in libc's hidden/stdlib.h instead of in each .c file that needs one
ok deraadt@ gsoares@ mpi@
9 years ago
deraadt
90378d363e
refactor option letter parsing into a subfunction, to increase clarity
about which options are turned on/off by 's' and 'S'
ok tedu
9 years ago
otto
0af523ebbd
Don't crash dumping malloc stats if malloc_init hasn't been called, noted by
David CARLIER
9 years ago
tedu
c3dcc81b75
Long ago, malloc internally had two kinds of failures, warnings and errors.
The 'A' option elevated warnings to errors, and has been the default for some
time. Then warnings were effectively eliminated in favor of everything
being an error, but then the 'a' flag turned real errors into warnings!
Remove the 'a' option entirely. You shouldn't have used it anyway.
ok tb tdeval
9 years ago
tedu
5724f1ae45
another case where bad things would happen after wrterror
9 years ago
tedu
57beaad82f
if somebody makes the mistake of disabling abort, don't deref null in
validate_junk. from Michal Mazurek
9 years ago
tedu
1bd8c9e70f
Integrate two patches originally from Daniel Micay.
1. Optionally add random "canaries" to the end of an allocation. This
requires increasing the internal size of the allocation slightly, which
probably results in a large effective increase with current power of two
sizing. Therefore, this option is only enabled via 'C'.
2. When writing junk (0xdf) to freed chunks (current default behavior),
check that the junk is still intact when finally freeing the delayed chunk
to catch some potential use after free. This should be pretty cheap so
there's no option to control it separately.
ok deraadt tb
9 years ago
guenther
ec1a04d68c
For now, permit overriding of the malloc family, to make emacs happy
9 years ago
guenther
c8272cfe98
Wrap <stdlib.h> so that calls go direct and the symbols not in the
C standard are all weak.
Apply __{BEGIN,END}_HIDDEN_DECLS to gdtoa{,imp}.h, hiding the
arch-specific __strtorx, __ULtox_D2A, __strtorQ, __ULtoQ_D2A symbols.
9 years ago
tedu
b4484c676a
improve realloc. when expanding a region, actually use the free page cache
instead of simply zapping it. this can save many syscalls in a program
that repeatedly grows and shrinks a buffer, as observed in the wild.
10 years ago
deraadt
75d428b273
Move to the <limits.h> universe.
review by millert, binary checking process with doug, concept with guenther
10 years ago
tedu
06084f37f2
rename kern enter/exit macros to malloc enter/leave to better reflect
what's going on.
10 years ago
tedu
69d8bb8294
a small tweak to improve malloc in multithreaded programs. we don't need
to hold the malloc lock across mmap syscalls in all cases. dropping it
allows another thread to access the existing chunk cache if necessary.
could be improved to be a bit more aggressive, but i've been testing this
simple diff for some time now with good results.
10 years ago
tedu
705f1bf46e
reduce obvious dependency on global g_pool by moving to local aliases
ok otto
10 years ago
deraadt
df559b50e4
extra evil spaces snuck in over the last while
10 years ago
otto
08ecfcb5b8
Move to a smaller rbytes buffer and skip a random part. Not to
improve the random stream itself (it doesn't), but to introduce
noise in the arc4random calling pattern. Thanks to matthew@ who
pointed out bias in a previous diff, ok deraadt@ matthew@
10 years ago
otto
7626939dd1
move random bytes buffer to be part of mmaped pages; ok tedu@
11 years ago
otto
547175abed
move all stats collecting under MALLOC_STATS; ok krw@
11 years ago
otto
17d6cb272d
fix MALLOC_STATS (not compiled in by default); ok tedu@
11 years ago
tedu
118f2caf23
factor out a bit of the chunk index code and use it to make sure that a
freed chunk is actually freeable immediately. catch more errors.
hints/ok otto
11 years ago
tedu
508b771a99
change to having four freelists per size, to reduce another source of
deterministic behavior. four selected because it's more than three, less
than five. i.e., no particular reason.
11 years ago
otto
d7088c5a04
fix MALLOC_STATS code that was broken in rev 1.159, not compiled in by default
11 years ago
deraadt
a14ce349c7
move reallocarray() to a seperate file so that -portable applications
can avoid reinventing the wheel
ok guenther schwarze
11 years ago
halex
3a717658e6
comment style fix
ok crickets@
11 years ago
tedu
74c23bc915
nibbles aren't enough random, use bytes. does a better job of picking
a free chunk at random and may allow to increase delayed chunk array.
ok otto
11 years ago
tedu
c0d30f0eb0
remove Z option and default to something halfway to J.
we always junk small chunks now, and the first part of pages,
but only after free. J still does the old thing. j disables everything.
Consider experimental as we evaluate performance in the real world.
ok otto
11 years ago
espie
41f1e88953
explain a bit more what's going on for stupid me.
okay otto@
11 years ago
otto
8a0e8854ef
Better, cleaner hash function that computes the same on be and le archs.
Should improve sparc64 and other be archs. ok matthew@ miod@
11 years ago
tedu
07d1cf3ec2
change mallocarray to reallocarray. useful in a few more situations.
malloc can, as always, be emulated via realloc(NULL).
ok deraadt
11 years ago
deraadt
00d28c4faf
Introducing: void *mallocarray(size_t nmemb, size_t size);
Like calloc(), except without the cleared-memory gaurantee
ok beck guenther, discussed for more than a year...
11 years ago
otto
d487e76537
print pid in error messages; ok reyk@
11 years ago
schwarze
93c318776d
Update Copyright notice; ok otto@ beck@ deraadt@.
This is merely a by-product of figuring out the amount of phk@ code
contained herein; i'm not planning to hack on this file.
11 years ago
beck
241e064849
Poul-Henning Kamp informed me he is allright with this licensing change.
11 years ago
deraadt
a728e0155c
avoid arithetic on void *
ok guenther otto
11 years ago