Skip to contentSkip to conversation

malloc problems

Linux-ia64 Bill Nottingham 3 participants 3 messages Apr 26, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · Donny Cooper

dynamic_area = (unsigned char *) malloc ( membytes );
printf(" dyn_area = %x %lx, mem= %x \n",dynamic_area,dynamic_area,membytes);

Result from Tom: (1-way BigSur)
dyn_area = 40000010 40000010, mem= 2000018

It looks like you forgot a prototype for malloc.

Bill

#1 lore raw

Bill,

This code is a small subset of a very large application, that runs on many platforms, an is being ported and tuned for IA64 Linux.
The executable builds and runs fine, but always grabs a different memory area on the one BigSur, as opposed to the others.

Thanks.

Donny

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Bill Nottingham
Sent: Thursday, April 26, 2001 10:03 AM
To: !IA64-Dist-Linuxia64 (E-mail)
Subject: [Linux-ia64] Re: malloc problems

Quoted 2 lines · Donny Cooper

dynamic_area = (unsigned char *) malloc ( membytes ); printf(" dyn_area = %x %lx, mem= %x

\n",dynamic_area,dynamic_area,membytes);

Quoted 3 lines

Result from Tom: (1-way BigSur)
dyn_area = 40000010 40000010, mem= 2000018

It looks like you forgot a prototype for malloc.

Bill

_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64

#2 lore raw
In reply to Bill Nottingham
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Donny Cooper

Donny> Bill, This code is a small subset of a very large Donny> application, that runs on many platforms, an is being ported Donny> and tuned for IA64 Linux. The executable builds and runs Donny> fine, but always grabs a different memory area on the one Donny> BigSur, as opposed to the others.

You didn't include a complete test case, so you shouldn't be surprised if you're sending people off to a wild goose chase. As Bill said, the code you quoted is indeed incorrect as it shows no declaration of malloc(), nor does it include <stdlib.h>.

Since you say your code works fine, let's assume that malloc() does get declared *somewhere*. Based on the addresses you quote:

	Result from Tom: (1-way BigSur)
	dyn_area = 40000010 40000010, mem= 2000018

	Result from Dick & Harry:(2-way BigSur & 4-way Lion)
	dyn_area = 10 2000000000000010, mem= 2000018

I'd say that the binary on "Tom" is an IA-32 binary. Please use "file" to verify and let us know (if it's not an IA-32 binary, then a kernel bug would be the next candidate).

For example, if I compile the attached test program once for IA-32 (t.x86) and once for IA-64 (t.ia64), I get:

	$ ./t.x86
	0x40134008
	$ ./t.ia64 
	0x20000000002a0010

Hope this helps,

	--david

--
#include <stdio.h>
#include <stdlib.h>

int main (int argc, char **argv) {

        return printf ("%p\n", malloc(2000018));
}