From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,97d3ded662883f7c,start X-Google-Attributes: gid111c93,public X-Google-ArrivalTime: 2001-01-10 14:54:44 PST Path: supernews.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!news.ksw.feedmania.org!newsfeed.mesh.ad.jp!portc01.blue.aol.com!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: rwgk@my-deja.com Newsgroups: comp.os.linux.alpha Subject: weird behavior of malloc() Date: Wed, 10 Jan 2001 22:43:04 GMT Organization: Deja.com Message-ID: <93iohn$m3c$1@nnrp1.deja.com> NNTP-Posting-Host: 128.3.132.173 X-Article-Creation-Date: Wed Jan 10 22:43:04 2001 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) X-Http-Proxy: 1.1 x73.deja.com:80 (Squid/1.1.22) for client 128.3.132.173 X-MyDeja-Info: XMYDJUIDrwgk Xref: supernews.google.com comp.os.linux.alpha:1844 System: Red Hat Linux release 6.2 (Zoot) Kernel 2.2.14-6.0smp on a 2-processor alpha On this system, malloc() returns pointers to places in memory that are very far apart. For example, one call returns 0x125f77510, and the next one 0x20000002010 (the first call only allocates 16 bytes or so, the second one about 160000 bytes). Unfortunately, this behavior is causing us problems. For use in a Fortran program, we compute the difference between the pointers returned by malloc() and a pointer to a Fortran reference array. The difference is divided by the size of Fortran INTEGER, and that result passed back from C to Fortran as a Fortran INTEGER. If the difference is too large for INTEGER, our program crashes. Our program is very large (>100000 lines) and it is practically impossible to find and replace all INTEGER that store offsets for dynamic memory allocation. Also, the program is running fine on another 64-bit architecture (IRIX64). Why does malloc() on the Alpha return pointers to places in memory that are so far apart? Could this be changed? Thanks for any comments, Ralf Sent via Deja.com http://www.deja.com/