From: laz@gonefishing.sk.ca (Larry Zimmerman)
Subject: Re: weird behavior of malloc()
Date: 10 Jan 2001 20:28:37 -0600 [thread overview]
Message-ID: <3a5d1a55$1@news3.accesscomm.ca> (raw)
In-Reply-To: 93iohn$m3c$1@nnrp1.deja.com
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.
next prev parent reply other threads:[~2001-01-11 2:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-10 22:43 weird behavior of malloc() rwgk
2001-01-11 0:09 ` Terrance Richard Boyes
2001-01-11 2:28 ` Larry Zimmerman [this message]
2001-01-11 16:38 ` Greg Lindahl
2001-01-11 16:07 ` Pierre Asselin
2001-01-11 18:25 ` T. Daniel Crawford
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox