Re: Jemalloc SEGV for 1MB chunk

From: Christoph Mallon <christoph.mallon_at_gmx.de>
Date: Wed, 28 Jan 2009 12:46:31 +0100
Channa schrieb:
> Hi All,
> I am using jemalloc.c source from FreeBSD-current source.
> When i allocate 1MB of memory using malloc() and use it as the below
> test shows
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> 
> int main()
> {
> 	int i;
> 	char *buf;
> 	size_t size = 1048576 ;
> 
> 	buf = malloc(size);
> 	for (i = 0; i < 1048576; i++)
> 		buf[i] = 'a';
> 	printf("The length of buff is : %d\n",strlen(buf));
> 	free(buf);
> 	return 0;
> }
> 
> When i try to call strlen(buf) SEGV is recived.
> 
> This behaviour is seen when only for 1MB chunk if i allocate
> memory lesser than 1MB no issues noticed.
> 
> Could anyone see similar problem?
> Is the above test wrong?
> Or some issue with huge memory allocation in jemalloc?
> 
> Your response will be very helpful.
> 
> Thanks & Regards,
> Channa

You did not NUL-terminate ('\0') the string.
Received on Wed Jan 28 2009 - 10:46:34 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:41 UTC