posix_memalign(&ptr, 32, 0 fails)
posix_memalign(&ptr, 32, 0 fails)
- Subject: posix_memalign(&ptr, 32, 0 fails)
- From: "Ronald S. Bultje" <email@hidden>
- Date: Wed, 27 Apr 2011 05:53:07 +0000
Hi,
I hope this is the right list for my problem. I have the following
problem (let's call this my testcase for the problem I'm seeing in my
application):
bash-3.2$ cat test.c
#include <stdlib.h>
int main(){
void *ptr = NULL;
if (posix_memalign(&ptr, 16, 0)) return;
if (ptr) free(ptr);
if (posix_memalign(&ptr, 32, 0)) return;
if (ptr) free(ptr);
}
bash-3.2$ gdb ./test
[..]
(gdb) r
Starting program: /private/tmp/test
Reading symbols for shared libraries +. done
test(72919) malloc: *** error for object 0x1001000a0: pointer being
freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal SIGABRT, Aborted.
0x00007fff88679616 in __kill ()
(gdb) bt
#0 0x00007fff88679616 in __kill ()
#1 0x00007fff88719cca in abort ()
#2 0x00007fff886316f5 in free ()
#3 0x0000000100000f17 in main () at test.c:7
It seems that posix_memalign() with alignment=16 accepts size=0 fine,
but with alignment=32, it does not. This works fine (as far as I can
see) on other systems that I have access to (Linux on PPC/x86/Arm,
Windows). System is MacOSX 10.6.7, on a recent Macbook Pro. Is this a
bug, and if so, is it a known bug?
Ronald
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden