* Re: VMS free() broken -- the saga continues
1992-09-25 9:20 VMS free() broken -- the saga continues Hans Granqvist
@ 1992-09-25 15:23 ` Jeff Diewald
1992-09-25 20:28 ` Charles M Richmond
1992-09-25 16:22 ` Paul S. Winalski
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Jeff Diewald @ 1992-09-25 15:23 UTC (permalink / raw)
Is it possible that the addresses you are looking at are in hex? If so, then
10070(hex) - 10000(hex) = 70(hex) = 112 (decimal). Thus - your areas do NOT
overlap. The need for 12 "extra" bytes, given typical overhead for memory
allocation schemes, or a very small intermediate allocation, would not be
at all surprising.
-------------------------------------------------------------------------------
Jeff Diewald EASYNET: VIRRUS::DIEWALD
Debug group INTERNET: diewald@virrus.zko.dec.com
Digital Equipment Corp.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: VMS free() broken -- the saga continues
1992-09-25 15:23 ` Jeff Diewald
@ 1992-09-25 20:28 ` Charles M Richmond
0 siblings, 0 replies; 6+ messages in thread
From: Charles M Richmond @ 1992-09-25 20:28 UTC (permalink / raw)
diewald@virrus.zko.dec.com (Jeff Diewald) writes:
>Is it possible that the addresses you are looking at are in hex? If so, then
>10070(hex) - 10000(hex) = 70(hex) = 112 (decimal). Thus - your areas do NOT
>overlap. The need for 12 "extra" bytes, given typical overhead for memory
>allocation schemes, or a very small intermediate allocation, would not be
>at all surprising.
>-------------------------------------------------------------------------------
> Jeff Diewald EASYNET: VIRRUS::DIEWALD
> Debug group INTERNET: diewald@virrus.zko.dec.com
> Digital Equipment Corp.
....or that 112 (decimal) is the next 8 byte boundary after 104 (decimal),
which is the smallest number of bytes that is both more than 100 and is
divisible by 8 bytes. Ne se pas?
Charlie
--
*****************************************************************************
* Charles Richmond Integrated International Systems Corporation *
* cmr@world.std.com (Temporary) cmr@chiechan.mro4.dec.com *
* Specializing in UNIX, X, Image Processing, and Communications. *
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: VMS free() broken -- the saga continues
1992-09-25 9:20 VMS free() broken -- the saga continues Hans Granqvist
1992-09-25 15:23 ` Jeff Diewald
@ 1992-09-25 16:22 ` Paul S. Winalski
1992-09-25 16:59 ` Paul S. Winalski
1992-09-28 16:06 ` jmeinke
3 siblings, 0 replies; 6+ messages in thread
From: Paul S. Winalski @ 1992-09-25 16:22 UTC (permalink / raw)
In article <hansg.717412853@risken>,
hansg@risken.vd.volvo.se (Hans Granqvist) writes:
|>
|>Has anyone encountered this problem?
|>A malloc() succeeding another malloc() returns a pointer to an area
|>OVERLAYING the previous, and no free() has been made between them, i.e.,
|>
|>a = malloc(100);
|>...
|>b = malloc(100);
|>
|>where a may turn out address 10000 and b address 10070 (construed
|>addresses here!)
|>
|>Is th is behaviour at all legal in any way? Does VMS malloc sometimes
|>return some sort of "shared memory" or what IN THE NAME OF KEN OLSEN is
|>this?
The only cases where I've ever seen this happen is where the user code between
the two calls to malloc() (the "..." in your example) have written outside
the allocated bounds of the memory and have damaged the control blocks that
malloc() uses to maintain its free storage pool. This can happen if, for
example, you malloc9() a string and fail to account for the NUL byte that
must terminate it (if you want a string 100 characters long, you must allocate
101 bytes). Just about any user programming error that causes memory
corruption (for example, arrays out of bounds, returning a pointer to an
auto variable, bad pointer arithmetic, writing outside the bounds of
malloc()'d memory) can cause this to happen.
Bottom line: there is indeed a bug somewhere, and it's 99.999% likely that
it's in your code, not in malloc().
--PSW
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: VMS free() broken -- the saga continues
1992-09-25 9:20 VMS free() broken -- the saga continues Hans Granqvist
1992-09-25 15:23 ` Jeff Diewald
1992-09-25 16:22 ` Paul S. Winalski
@ 1992-09-25 16:59 ` Paul S. Winalski
1992-09-28 16:06 ` jmeinke
3 siblings, 0 replies; 6+ messages in thread
From: Paul S. Winalski @ 1992-09-25 16:59 UTC (permalink / raw)
In article <hansg.717412853@risken>,
hansg@risken.vd.volvo.se (Hans Granqvist) writes:
|>
|>Has anyone encountered this problem?
|>A malloc() succeeding another malloc() returns a pointer to an area
|>OVERLAYING the previous, and no free() has been made between them, i.e.,
|>
|>a = malloc(100);
|>...
|>b = malloc(100);
|>
|>where a may turn out address 10000 and b address 10070 (construed
|>addresses here!)
|>
|>Is th is behaviour at all legal in any way? Does VMS malloc sometimes
|>return some sort of "shared memory" or what IN THE NAME OF KEN OLSEN is
|>this?
Indeed what you describe is not supposed to happen. There is a bug somewhere,
but it's 99.999% likely that it's in your code, not in malloc(). If your
program writes on top of the data structures that malloc() uses to keep track
of its free memory pools, things like this can happen. Look for arrays out
of bounds, cases of allocating less memory than you actually are using (for
example, if you're going to strcpy() a 100 byte string, the destination must
be 101 bytes long), passing pointers to variables of storage class auto out
of the routine where they're declared, bad pointer arithmetic, etc.
--PSW
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: VMS free() broken -- the saga continues
1992-09-25 9:20 VMS free() broken -- the saga continues Hans Granqvist
` (2 preceding siblings ...)
1992-09-25 16:59 ` Paul S. Winalski
@ 1992-09-28 16:06 ` jmeinke
3 siblings, 0 replies; 6+ messages in thread
From: jmeinke @ 1992-09-28 16:06 UTC (permalink / raw)
In article <hansg.717412853@risken>, hansg@risken.vd.volvo.se
(Hans Granqvist) writes:
> Has anyone encountered this problem?
> A malloc() succeeding another malloc() returns a pointer to an area
> OVERLAYING the previous, and no free() has been made between them, i.e.,
I don't have the latest version of VAX C, but it used to be
that lib$get_vm and lib$free_vm were incompatible with malloc
and free. If you are using either of those library functions
in some other part of your application, perhaps by linking
with a library that uses them, that may be your problem.
--
Jim Meinke, Simpact Associates 619-565-1865
9210 Sky Park Court jmeinke@dcs.simpact.com
San Diego, CA 92123
"I really didn't say everything I said." -- Yogi Berra
^ permalink raw reply [flat|nested] 6+ messages in thread