comp.lang.ada
 help / color / mirror / Atom feed
* Finalization and Garbage Collection: a hole in the RM?
@ 1996-08-26  0:00 Franco Mazzanti
  1996-08-29  0:00 ` Robert A Duff
  1996-08-29  0:00 ` Robert A Duff
  0 siblings, 2 replies; 14+ messages in thread
From: Franco Mazzanti @ 1996-08-26  0:00 UTC (permalink / raw)



I could not find are rule describing what could/should happen when an
exception is raised by a Finalization routine called by the garbage
collector.  [RM 7.6.1.(14)] says that this is a bounded error, and this,
fortunately rules out any erroneous execution. But the list of the 
possible effects does not contain the case of Finalize being called
by a garbage collector. 

Should this be interpreted as if the garbage collector should act exactly
as any other Ada task, and handle in its own way any possible exception
raised by Finalize? 
[RM 13.12(6)] says something on the Garbage Collection, but in an a way that
does not seem to mandate at all the above point of view.

Missing something??

Franco Mazzanti  <mazzanti@iei.pi.cnr.it>
I.E.I. - C.N.R.




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Finalization and Garbage Collection: a hole in the RM?
@ 1996-08-30  0:00 Franco Mazzanti
  1996-08-30  0:00 ` Robert A Duff
  0 siblings, 1 reply; 14+ messages in thread
From: Franco Mazzanti @ 1996-08-30  0:00 UTC (permalink / raw)




> >I could not find are rule describing what could/should happen when an
> >exception is raised by a Finalization routine called by the garbage
> >collector. ...


> One possible answer is that the exceptions get lost, as for a task.
> This makes debugging rather painful.
> ...

> Another possibility is to kill the whole program, trap into the
> debugger, record the error in an error log, or whatever is appropriate
> for catastrophic failures on your system.
> ...

> 
> Another possibility is to not collect finalizable objects.  
> ...

> In any case, the design of Ada 95 does not answer your question, so I'd
> say it's fair for the gc implementer to design a solution to the
> problem.  There's always the cop-out of letting the user choose from
> among several bad options.  ;-)
> 
> - Bob
> 

Well, I understand that a clean integration of garbage collection in Ada
requires the solution of several difficulties.

What is really scaring me, are not just the problems inherent to GC,
but the fact that there are hidden "holes" in the language definition,
and that the effect of a program falling in this "holes" is completely
undefined.

Are there any other holes like this one are hiding there?

I am trying to write a roadmap to erroneous executions and other 
unpredictabilities in Ada95, so for me it would be important to find all
the possible issues of this kind.

Anybody knows?


Franco Mazzanti

------------------------------------------------------------
   Dr. Franco Mazzanti
   Istituto di Elaborazione della Informazione
   Via S.Maria 46, 56126 Pisa, ITALY
   Tel: +39-50-593447/593400, Fax: +39-50-554342
   e-mail: mazzanti@iei.pi.cnr.it
------------------------------------------------------------




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Finalization and Garbage Collection: a hole in the RM?
@ 1996-09-02  0:00 Franco Mazzanti
  1996-09-03  0:00 ` Robert Dewar
  1996-09-03  0:00 ` Robert A Duff
  0 siblings, 2 replies; 14+ messages in thread
From: Franco Mazzanti @ 1996-09-02  0:00 UTC (permalink / raw)



Robert A Duff wrote:
>
> >I am trying to write a roadmap to erroneous executions and other
> >unpredictabilities in Ada95, so for me it would be important to find all
> >the possible issues of this kind.
>
> Are you interested in erroneous/unpredictable stuff in general, or are
> you interested specifically in issues related to garbage collection?

I am interested in erroneous/unpredictable(in the sense of the RM, which is
almost a synonym of "erroneous") stuff in general.

> The index of the RM and AARM contains entries for "erroneous" and
> "bounded error" that will let you track down all the cases.

"Bounded Errors" are not considered by the RM (not from me) cases of
true "unpredictability". A program with bounded errors is not erroneous.

The entry "erroneous" in the RM (and AARM) Index does not allow to track
down all the cases. We have to look also at the entries "abnormal" and
"unspecified".  Even so, there is a small aspect which is still non captured
([RM 13.13.2.(35)]).  Finally, we should have to consider also any
possible language "holes" (i.e. I cannot take for granted that the RM is
"perfect").

> Another
> source of unpredictability is when the run-time semantics says
> "arbitrary order".  I don't think that's in the index, but you could use
> an editor to search the ascii version of the RM.

For what I can see, according to [RM 1.1.4(18)]  (see below), there is
nothing "unpredictable" ("erroneous") in things being executed in
"arbitrary order".

[RM 1.1.4(18)]:
"18   Whenever the run-time semantics defines certain actions to happen in an
arbitrary order, this means that the implementation shall arrange for these
actions to occur in a way that is equivalent to some sequential order,
following the rules that result from that sequential order.  When evaluations
are defined to happen in an arbitrary order, with conversion of the results
to some subtypes, or with some run-time checks, the evaluations, conversions,
and checks may be arbitrarily interspersed, so long as each expression is
evaluated before converting or checking its value.  Note that the effect of a
program can depend on the order chosen by the implementation.  This can
happen, for example, if two actual parameters of a given call have side
effects."

In any case, if you are interested in reviewing the draft version of the
document (when it will be ready), I would be happy to make it available to you
(or anybody else interested). Just let me know.

Franco

------------------------------------------------------------
   Dr. Franco Mazzanti
   Istituto di Elaborazione della Informazione
   Via S.Maria 46, 56126 Pisa, ITALY
   Tel: +39-50-593447/593400, Fax: +39-50-554342
   e-mail: mazzanti@iei.pi.cnr.it
------------------------------------------------------------




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Finalization and Garbage Collection: a hole in the RM?
@ 1996-09-04  0:00 Franco Mazzanti
  1996-09-08  0:00 ` Robert Dewar
  0 siblings, 1 reply; 14+ messages in thread
From: Franco Mazzanti @ 1996-09-04  0:00 UTC (permalink / raw)




Robert Dewar said:
 "Well anyone can use language any way they like, but in the normal English
 meaning of the word unpredictable (which is the proper one to be using,
 since unpredictable is not  technical term), of course bounded errors
 result in unpredictable program execution, in that you cannot predict
 what will happen. "

Probably a gave a too technical meaning to the term "predictable".
In effect, the RM index doen not contain the entry "unpredictable"
or "predictable" or "not predictable". And this is a sign that the
use of the term was not meant to be strictly "technical".

However, it is also true that the Reference Manual associates
the (normal English) term "unpredictable" (or "not predictable")
only to erroneous executions, and not to bounded errors.
Therefore encouraging, expecially to those people whose native language
is not English, the impression that it is correct to associate the
(normal English) term "unpredictable" only to erroneous executions.

Even more, in 13.9.1(11) it is explicitly said that the use of an invalid
value (which is probably the "least predictable" case of bounded errors)
does not lead to "unpredictable" execution.

Quoting RM 13.9.1(11):
    "If the representation of the object does not represent a value of
    the object's type, the semantics of operations on such
    representations is implementation-defined, but does not by itself
    lead to erroneous or unpredictable execution, or to other objects
    becoming abnormal."

I agree with Robert that "anyone can use language any way they like"
(also the authors of the Reference Manual), but I was not too wrong when
I said that the RM did not consider bounded errors as cases of true
"unpredictability" (whether or not this is correct from the point
of view of normal English usage of the term "predictable").

By the way, I completely agree that bounded-errors are not like
non-deterministic behaviour (just because they ARE errors).

Franco Mazzanti




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Finalization and Garbage Collection: a hole in the RM?
@ 1996-09-06  0:00 Franco Mazzanti
  1996-09-06  0:00 ` Robert A Duff
  0 siblings, 1 reply; 14+ messages in thread
From: Franco Mazzanti @ 1996-09-06  0:00 UTC (permalink / raw)



Robert A Duff said:

> Your best bet is to get the ascii version of the RM or AARM, and search
> in a text editor for "erroneous", "unspecified", "implementation
> defined", etc.  (I say "impl def", because it is theoretically possible
> for an implementation to take something that's implemenation defined,
> and define it to be erroneous.  In most cases, this is highly unlikely.
> You can probably tell by looking at each case whether or not its likely
> in practise.)

I have already done  that for "erroneous", (un, not)"specified",
"abnormal", and several others.  But no, I did not go through
implementation-defined aspects. I thought they cound not be transformed
by the implementation into erroneous executions ... You have opened
for me a new can of worms ...

> 
> Also, read 11.6.
> 

I already read this piece of cake many times, and still have to figure
out what it does really imply ... :-) 
I plan to reinvestigate that aspects soon.


> >For what I can see, according to [RM 1.1.4(18)]  (see below), there is
> >nothing "unpredictable" ("erroneous") in things being executed in
> >"arbitrary order".
> 
> Well, it depends how unpredictable you mean -- erroneous things are
> totally unpredictable, and can cause the program to behave outside the
> normal semantic model.  Bounded errors and arbitrary orders are only a
> little bit unpredictable (i.e. there's a well-defined set of
> possibilities).  Certainly *any* form of nondeterminism can cause
> trouble -- portability problems, programs that work with optimization
> turned off but not with optimization turned on, etc.  And it's worse in
> theory than in practise, since most compilers don't (for example) roll
> dice on every subprogram call to determine the order of parameter
> evaluation.
> 
> Thankfully, Ada has far fewer cases of totally unpredictable behavior
> than certain other palindromic languages.  ;-)  And Ada 95 eliminates one
> of the worst cases of erroneousness in Ada 83 -- uninitialized
> variables.
> 
> - Bob

I agree, but currently I am just trying to understand only the "totally
unpredictable" aspects. That is enough for now.

Returning to implementation-defined aspects, of the 136 cases mentioned
in Appendix M, most of them give  to implementations some freedom
in supporting some aspect, but without affecting the program run-time
semantics, or affecting the run-time semantics in a well defined way.
(see E.g. M(34) the order of elaboration of library items).

Other aspects, instead, give to implementations the freedom the change
or extend the normal semantic model, or the freedom to complete some
unspecified aspects of the normal semantic model with erroneousness.
And these are the best candidates for potential erroneous executions.
(e.g. M(14): The operations on "nonstandard integer types"  or
      M(38): The consequences of violating limitations on Restrictions
              pragmas.)
They are not many, I counted only 13 of them.
[ M(4,10,14,15,21,38,42,44,52,58,77,81,85) ]

A third group, finally, allows a function call to return an
"implementation-defined" result [M(20,40,86,87,123,124,127,128,131)].
(e.g. M(123): The result of a floating point arithmetic operation in 
              overflow situations, when the Machine_Overflows attribute 
              of the result type is False. 
 or  M(86) The result of the Task_Identification.Image attribute.)

The erroneousness of the program might be affected if the implementation
were allowed to return an "abnormal result".
Is this  possibility allowed by the RM, or the fact that some value
MUST be returned, even if implementation-defined, can be seen as
automatically ruling out the possibility or returning an abnormal 
value (which would probably be erroneous by itself).?

In other words: can a function required to return a (implementation
defined) result, directly cause an erroneous execution?
Is the attemp to return an abnormal result directly erroneous?

Franco




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: Finalization and Garbage Collection: a hole in the RM?
@ 1996-09-09  0:00 Franco Mazzanti
  0 siblings, 0 replies; 14+ messages in thread
From: Franco Mazzanti @ 1996-09-09  0:00 UTC (permalink / raw)



Robert said:

" In the context of discussing whether bounded errors are predictable
 or not. But there is a HUGE difference between
implementation-defined
 and a bouned error. If something is implementation defined, then
 Annex M must specify its behavior, and the behavior is entirely
 predictable.
 However, reading paragraphs 9-11 here, I agree there is a lot of
 confusion over what is a bounded error, and what is implementation
 defined, and the RM does not seem to recognize the HUGE difference I
 mention above :-) 
 Bob (Duff), can you sort out the intention here, para 9 seems to say
 that evaluating the value of an object with an invalid
 reprsentatoin is a bounded error, and para 11 seems to say that is
 implementation defined. Even for someone who *is* a native speaker
 and reader of English, this is completely confusing to me :-) "


I cannot speak for the RM authors (hence cannot guarantee for the
correcntess of the interpretation) but I can present my
interpretation of the fact, as an "external" view (hence not 
influenced by unwritten knowdegde or discussions, nor by any strong 
reliance on the "normal English meaning of terms").

After all, the picture seems to me rather consistent:

"implementation-defined" aspects are of two types:

Most of them give  to implementations some freedom in supporting 
some aspect, but without affecting the program run-time semantics, 
or affecting the run-time semantics in a well defined way.
(see E.g. M(34) the order of elaboration of library items).
Others, give to implementations the freedom the change or
extend the normal semantic model, or the freedom to complete some
unspecified aspects of the normal semantic model even with 
erroneousness (e.g.M(38)).
In any case, the particular choice selected by the implementation
MUST BE DOCUMENTED.

Clearly, if an implementation writes that a certain
implementation-defined action is erroneous, the execution can still
be "(totally) unpredictable", even if the possible behavior has been
"documented" by the implementation.

Bounded Errors, instead, do not carry the possibility of 
"(totally) unpredictable" (i.e. "erroneous") behavior. 
What might actually happen in these cases, is required to be
documented only if Annex H is supported [H.2(1),M(33)]).
Usually, the RM explicitly defines a well defined set of alternatives
for the possible program behaviour in presence of bounded errors. 

In a few cases, however, the RM does not explicitly define this set
of alternatives, but lets the implementation to define it (as an
implementation-defined aspect).  Very consistently, however, requires
that all these implemention-defined alternatives to be "well
defined", keeping out of the door the possibility that an
implemenation reintroduces erroneous executions within
bounded-errors.

Conclusions:

Bounded Errors:  
    Are errors.
    Possible behavior usually defined the RM, in a few cases
      defined by the implementation. 
    Behaviour is in any case not erroneous.
    Actual behaviour documented if Annex H is supported.

Implementation Defined: 
    Are not necessarily errors.
    Possible behavior sometimes explicitly defined by the RM,
      sometimes defined by the implementation. 
    In certain cases, the behaviour can also be erroneous 
           (in which case we have an error) .
    Actual behaviour always documented.


Franco Mazzanti




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~1996-09-09  0:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-26  0:00 Finalization and Garbage Collection: a hole in the RM? Franco Mazzanti
1996-08-29  0:00 ` Robert A Duff
1996-08-29  0:00 ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-08-30  0:00 Franco Mazzanti
1996-08-30  0:00 ` Robert A Duff
1996-09-02  0:00 Franco Mazzanti
1996-09-03  0:00 ` Robert Dewar
1996-09-03  0:00 ` Robert A Duff
1996-09-04  0:00 Franco Mazzanti
1996-09-08  0:00 ` Robert Dewar
1996-09-06  0:00 Franco Mazzanti
1996-09-06  0:00 ` Robert A Duff
1996-09-07  0:00   ` Robert Dewar
1996-09-09  0:00 Franco Mazzanti

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