NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Difference in malloc's behavior in 6.0



On Tue, Dec 04, 2012 at 11:04:22PM +0530, Mayuresh wrote:
> "NetBSD's malloc seems to have changed. In gprolog we use tagged pointers.
> So we have to use 3 bits of the pointers. On 32 bits machine, we use
> 4-bytes alignement so we can use the 2 least significant bits (b1 and b0).
> The last bit used is the most significant one (b31). Classically, malloc
> (sbrk) does not return data with this bit set to 1 but some implementation
> does (it occurs often when malloc relies on mmap to allocate memory). So I
> fixed this using the dl_malloc (Doug Lea malloc)."

netbsd-6 uses jemalloc. It provides natural alignment for short
allocations and 16 Bytes alignment for larger ones. The correct fix is
to either make sure that allocations have a minimal size of a multiple
of 4 Bytes and/or use posix_memalign. Note that using the latter avoids
making any such assumptions at all.

Joerg


Home | Main Index | Thread Index | Old Index