From: Peter Hermann on
Georg Bauhaus <rm-host.bauhaus(a)maps.futureapps.de> wrote:
> I'm reading a few presentation pages that advertise the strengths
> of Ada. One sheet compares monitor functionalities as present
> in Java and Ada. Java needs much care not to break
> a monitor. Ada is shown not to have this problem.
>
> 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:69:24: warning: possible unprotected access to protected data

> end expose;
> end SynchNode;
>
> end Monitor;


From: Jerry van Dijk on
"J-P. Rosen" <rosen(a)adalog.fr> writes:

> With enough pointers, you can make anything unreliable ;-)

That just went into my signature file :-)

--
-- Jerry van Dijk
-- Leiden, Holland
--
-- The early bird may get the worm, but the second mouse gets the cheese!!
From: Marco on
thank you