From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Presentations on-line - Ada&SPARK for Education&Research
Date: Fri, 5 Mar 2010 10:19:06 +0100
Date: 2010-03-05T10:19:03+01:00 [thread overview]
Message-ID: <wq1o9enode9n$.lc2okc8u5mnz$.dlg@40tude.net> (raw)
In-Reply-To: 4b90babf$0$7625$9b4e6d93@newsspool1.arcor-online.net
On Fri, 05 Mar 2010 09:03:08 +0100, Georg Bauhaus wrote:
> True? With some effort, it seems possible to break an Ada
> monitor implemented as a protected object.
>
> package Monitor is
>
> type SynchNode;
> type Linkage is access all synchnode;
> type data is access all integer;
>
> protected type synchnode is
> procedure Link (x : Linkage);
> procedure Expose (N : out Data);
> private
> Outgoing : aliased Integer := 0;
> end SynchNode;
>
> end Monitor;
>
> package body monitor is
>
> protected body synchnode is
> procedure link (X : Linkage) is
> View : Data; -- X's data
> begin
> X.Expose(View);
> View.all := View.all + 1; -- <-- unprotected
> end link;
>
> procedure Expose (N : out Data) is
> begin
> N := Outgoing'unchecked_access;
monitor.adb:13:25: warning: possible unprotected access to protected data
Which pins down broken design.
> end expose;
> end SynchNode;
>
> end Monitor;
With even less efforts you can break anything:
X : SynchNode;
Y : Float;
for Y'Address use X'Address;
begin
Y := sqrt (Y);
----------------------------------
1. Do not use pointers
2. Do not use global variables
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2010-03-05 9:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-02 21:22 Presentations on-line - Ada&SPARK for Education&Research Dirk Craeynest
2010-03-05 8:03 ` Georg Bauhaus
2010-03-05 9:14 ` J-P. Rosen
2010-03-05 10:46 ` Georg Bauhaus
2010-03-06 8:43 ` Jerry van Dijk
2010-03-08 5:54 ` AdaMagica
2010-03-05 9:19 ` Dmitry A. Kazakov [this message]
2010-03-05 12:11 ` Peter Hermann
2010-03-06 12:40 ` Marco
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox