From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,97d3ded662883f7c X-Google-Attributes: gid111c93,public X-Google-ArrivalTime: 2001-01-10 18:30:09 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!newsfeed.direct.ca!look.ca!cyclone-sjo1.usenetserver.com!news-out.usenetserver.com!news.sanjose1.Level3.net!Level3.net!news-west.eli.net!news.chatlink.com!news3.accesscomm.ca From: laz@gonefishing.sk.ca (Larry Zimmerman) Newsgroups: comp.os.linux.alpha Subject: Re: weird behavior of malloc() Date: 10 Jan 2001 20:28:37 -0600 Organization: Budget Internet Message-ID: <3a5d1a55$1@news3.accesscomm.ca> References: <93iohn$m3c$1@nnrp1.deja.com> NNTP-Posting-Host: news3.accesscomm.ca MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.chatlink.com 979180124 16196 204.83.142.119 (11 Jan 2001 02:28:44 GMT) X-Complaints-To: abuse@chatlink.com NNTP-Posting-Date: 11 Jan 2001 02:28:44 GMT X-Newsreader: knews 1.0b.1 X-Original-NNTP-Posting-Host: 24.72.3.110 X-Original-Trace: 10 Jan 2001 20:28:37 -0600, 24.72.3.110 Xref: supernews.google.com comp.os.linux.alpha:1850 In article <93iohn$m3c$1@nnrp1.deja.com>, rwgk@my-deja.com writes: > 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. This problem was discussed in the "axp-list" some time ago. Malloc gets memory at low addresses for small chunks of data and at large addresses for large chunks of data. I'm not sure why you would try the address difference method to get memory size, but I'm pretty sure there is no reliable way to get this to work on Alpha with GNU tools. > .... Why does malloc() on > the Alpha return pointers to places in memory that are so far > apart? Could this be changed? I think one of the Digital engineers who worked on the Linux Alpha port explained this, but I don't recall the details. I don't think it would be easy to change in gcc or g77. Are you using Compaq's compilers - they may have a way of working around this problem. Larry Z. -- .signature withheld pending a patent/copyright search.