home · projects · papers · blog · gallery · contact
anil madhavapeddy // anil.recoil.org

mmap-based malloc on OpenBSD

09 August 2004   |   Anil Madhavapeddy   |   tags:   |   all posts

Thierry Deval has recently committed an impressive implementation of malloc that uses mmap instead of the older sbrk to allocate memory in OpenBSD. The advantage of the new approach is that it allows all the neat randomization features that have been added to OpenBSD recently to happen transparently in malloc (so that you don't just get consecutive pages back as in most operating systems). The downside is a slight slowdown, but in this age of insane CPUs, who cares?

It has had the side-effect of exposing a number of latent bugs in programs which silently access memory locations larger than the area they malloced; I fixed one which had remained lurking in my gcc bounds checker (see gcc-local) for over a year, and other bugs have cropped up in programs as important as newfs. Until someone goes through the pain of porting the awesome Valgrind to OpenBSD, being able to expose more bugs this way is pretty useful.

blog comments powered by Disqus