[uClinux-dev] core dump when allocating memory

From: aavan@263.net
Date: Fri Sep 14 2001 - 00:44:48 EDT


Hi, all

I had wrote a simple application tester:

#include 
#include 

int main(void)
{
	char *buf;
	int size = 100000, c = 0;

	while(1) {
		printf("%d\n", c++);
		fflush(stdout);

		buf = (char *) malloc(size);
		if (buf == NULL) {
			printf("mallco error--\n");
			fflush(stdout);
			return (-1);
		}
		(void) free(buf);
	
	}

	printf("ok\n");
	fflush(stdout);

	for (;;);
}

The core dump when I executed this tester app, in this case the c equal to 70. There still are same problem when I change the size for malloc(). If I change the size to 10000, then the core dump when the c equal to 599.

I do a test, I change the loop condition to "while (c < 69)" and type '#testapp &' to run this application. and type 'ps' command after the screen display "ok". The application size is 69xx! Why?

It seem the free() does not free the memory buffer! Is this a bug of malloc() and free()?
Please give me a hint, thanks a lot!

Regards,
Aavan




___________________________________________VCD5元,DVD10元百元数码相机荟萃展卖华语排行榜颁奖典礼加入书友会获精美礼品 

This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/


This archive was generated by hypermail 2.1.4 : Thu Sep 19 2002 - 13:20:11 EDT