[Beowulf] memory allocation on x86_64 returning huge addresses

daniel.kidger at quadrics.com daniel.kidger at quadrics.com
Mon Feb 7 10:18:33 PST 2005


Roland,

Sigh!  :-)

malloc can return any address it so wishes. 
Don't forget that this is a *virtual* address and so is not bounded by physical memory.

A 64-bit O/s with say 8GB RAM can easily have stack addresses in the window 1TB - 2TB, and heap address even higher (!)

I guess your real problem is that you are porting a (Fortran) program whose authors did not understand that it might ever run on a 64-bit machine. Your code does a malloc and then tries to store this in an I4 Fortran Integer. This would only be gaurunteed to work on a 32-bit architecture like say a Pentium.

So Solutions?
  1. since this is x86_64 simply run your compile your program with a 32-bit compiler
You can still run under under the 64-bit O/S
  2. Mend your application to store addresses in I8 variables, but keep I4 for other stuff if you wish. 
  3. (dubious) only save the lower 32-bits of the addresses in your I4 variables and then when being used add the known offset to yield the original 64-bit address. The offset is likely to be constant for all variables in your programs but ymmv.
  4. Port your code away from using malloc() altogether. Recently (well make that 15 years), Fortran has had its own dynamic memory allocation- the allocate() function.
 


Hope this helps,
Daniel.

--------------------------------------------------------------
Dr. Dan Kidger, Quadrics Ltd.      daniel.kidger at quadrics.com
One Bridewell St., Bristol, BS1 2AA, UK         0117 915 5505
----------------------- www.quadrics.com --------------------


> -----Original Message-----
> From: Roland Krause [mailto:rokrau at yahoo.com]
> Sent: 07 February 2005 17:02
> To: beowulf at beowulf.org
> Subject: [Beowulf] memory allocation on x86_64 returning huge 
> addresses
> 
> 
> I am trying to dynamically allocate memory for a Fortran-77 code that
> is supposed to run in I4 R4 mode on an x86_64 running SuSE-9.2 with a
> kernel.org 2.6.9 kernel. The machine has 8GB memory and memory has to
> be allocated in one large chunk. 
> 
> The problem is that malloc returns an address that is way beyond
> 8billion which is not what I had expected.
> 
> Does anybody why Linux gives me an address that is outside 
> the physical
> memory range? 
> 
> Does anybody whether there are any kernel parameter that affect this
> behavior? 
> 
> Any pointers to some good reading about the Linux VM would also be
> appreciated. 
> 
> 
> Regards
> Roland
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Mail - now with 250MB free storage. Learn more.
> http://info.mail.yahoo.com/mail_250
> _______________________________________________
> Beowulf mailing list, Beowulf at beowulf.org
> To change your subscription (digest mode or unsubscribe) 
> visit http://www.beowulf.org/mailman/listinfo/beowulf
> 




More information about the Beowulf mailing list