From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,504e971efe6c792a X-Google-Attributes: gidf7344,public X-Google-Thread: 1164f8,504e971efe6c792a X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1992-09-25 06:57:53 PST Xref: sparky comp.os.vms:15614 comp.sys.dec:5222 Newsgroups: comp.os.vms,comp.sys.dec Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!deccrl!news.crl.dec.com!rdg.dec.com!adserv.enet.dec.com!winalski From: winalski@adserv.enet.dec.com (Paul S. Winalski) Subject: Re: VMS free() broken -- the saga continues Message-ID: <1992Sep25.162242.21373@rdg.dec.com> Sender: news@rdg.dec.com (Mr News) Reply-To: winalski@adserv.enet.dec.com (Paul S. Winalski) Organization: Digital Equipment Corporation, Nashua NH References: Date: Fri, 25 Sep 1992 16:22:42 GMT In article , 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