comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado Alves <amado.alves@netcabo.pt>
To: comp.lang.ada@ada-france.org
Subject: Re: Format string bugs & race conditions
Date: Sun, 17 Oct 2004 13:28:20 +0100
Date: 2004-10-17T13:28:20+01:00	[thread overview]
Message-ID: <mailman.13.1098016133.10401.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <1097990937.246146@yasure>

> /*  If lockfile already exists, wait until it goes away.  */
> while((p = fopen("lockfile", "r"))) {
>     fclose(p);
>     sleep(1);
> }
> /*  (race)  */
> p = fopen("lockfile", "w");
> /*  Access the stuff which lockfile is supposed to protect from
>  *  multiple access.  But of course it doesn't.  */
> fclose(p);
> remove("lockfile");
> 
> Ada just makes it easier to implement this bug within a single
> instance of the executable.

No. Using files for locks is equally easy to implement and equally buggy 
in any language. But in Ada you would implement a lock as a protected 
object and be safe from race conditions by definition.

Regarding format strings my experience confirms that the C approach is 
buggy and Ada is not. In Ada you can format even better than in C and 
very safely even without leaving the standard. Resources include: Put 
and Get procedures for all scalar types, all bases; actual format 
strings, COBOL picture strings, in Annex F; the 'Image attribute, handy 
for quick instrumentation. Happy formating :-)




  parent reply	other threads:[~2004-10-17 12:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-16  9:28 Format string bugs & race conditions Hans Van den Eynden
2004-10-16 13:26 ` Stephen Leake
2004-10-16 15:09   ` Pascal Obry
2004-10-16 17:55 ` Jeffrey Carter
2004-10-17  5:28   ` Benjamin Ketcham
2004-10-17  9:14     ` Martin Dowie
2004-10-17 19:18       ` Benjamin Ketcham
2004-10-17 22:41         ` Martin Dowie
2004-10-18  7:57         ` Ole-Hjalmar Kristensen
2004-10-19 16:20           ` Warren W. Gay VE3WWG
2004-10-17 12:28     ` Marius Amado Alves [this message]
2004-10-17 17:28       ` Larry Kilgallen
2004-10-17 17:11     ` Larry Kilgallen
2004-10-18  0:24     ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox