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

Bug#156697: libc6: posix_memalign() uses its arguments incorrectly



Package: libc6
Version: 2.2.5-13
Severity: normal

When I invoke posix_memalign() like this (pagesize == 4096, BUFSIZE == 12M):

	char *s;
	posix_memalign(&s, pagesize, BUFSIZE)

It fails, but does not set errno with a reason. However, when I invoke
it like this:

	posix_memalign(&s, BUFSIZE, pagesize)

It succeeds, and allocates a suitable memory region (if I decrease
BUFSIZE below what my application really needs, it segfaults just as
one would expect). However, the allocated region is aligned to the size
of the allocated memory region (if I decrease BUFSIZE, the alignment
also becomes more lax).

The documentation states:

	Function: int posix_memalign (void **memptr, size_t alignment, size_t size) 

...which means (I think( that the first thing I tried was the correct one.
These are the versions of gcc I tried:

gcc version 2.95.4 20011002 (Debian prerelease)
gcc version 3.0.4
gcc version 3.1.1
gcc version 3.2 20020809 (Debian prerelease)

I suspect that the fix is trivial :)

-- System Information:
Debian Release: unstable
Architecture: i386
Kernel: Linux bzzrt 2.4.19-wsl #1 Tue Aug 6 04:13:00 CEST 2002 i686
Locale: LANG=C, LC_CTYPE=C

-- no debconf information




Reply to: