Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: rbowman Newsgroups: comp.os.linux.misc Subject: Re: VMS Date: 21 Jun 2025 05:53:15 GMT Lines: 43 Message-ID: References: <87tt4i9nw5.fsf@eder.anydns.info> <102l0h9$fjtb$5@dont-email.me> <4_GdncCsf-Nqe8n1nZ2dnZfqnPSdnZ2d@giganews.com> <103392c$lpbg$5@dont-email.me> <1033o4a$1qj6$3@dont-email.me> <1033tv1$3aqu$3@dont-email.me> <1034pj8$a74s$1@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net 9pPi1XNxNJvh0MkAmjZ7hAOd0nmdGurhshcn7rkTRMJ2nTAkpS Cancel-Lock: sha1:BblyDwJAFvgmZmdsYxG/PUSCGTo= sha256:PZaUsddKW4Q+JEZpwMYoFjUMbkZYIyrr28yTuSwCWxE= User-Agent: Pan/0.160 (Toresk; ) Xref: csiph.com comp.os.linux.misc:68972 On 21 Jun 2025 03:43:56 GMT, Robert Riches wrote: > On 2025-06-21, rbowman wrote: >> On Fri, 20 Jun 2025 23:07:20 -0000 (UTC), Rich wrote: >> >>> Very likely, but the idea was to protect the typical programmer from >>> their own common mistakes (of not carefully checking error return >>> codes or buffer lengths, etc.). I.e. the typical 9-5 contract >>> programmer, not the Dennis Ritchie's of the world. >> >> I'm paranoid enough that I check the return of malloc and try to log >> the problem even though I'm probably screwed at that point. It has >> pointed out errors for calloc if you've manged to come up with a >> negative size. >> >> I have worked with programmers that assumed nothing bad would ever >> happen. >> Sadly, some had years of experience. > > Some years ago, I heard of a bug related to use of malloc. The code had > _intended_ to dynamically allocate storage for a string and the > terminating null byte. It was _intended_ to do this: > > dest = malloc(strlen(src)+1); > > Instead, a paren was misplaced: > > dest = malloc(strlen(src))+1; > > IIUC, the next line copied the src string into the newly- allocated > destination. > > Those who had worked on that project longer said the bug had been latent > in the code for several years, most likely with alignment padding > masking the bug from being discovered. Curiously, the bug made itself > manifest immediately upon changing from a 32-bit build environment to a > 64-bit build environment. We picked up quite a few bugs moving from AIX to Linux. AIX was very tolerant of null pointers. Building for Windows using the MKS toolkit was also interesting. I've fixed 20 year old bugs that were lurking there waiting for the right alignment of the planets.