From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,714a9fe4718c9803 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!feed.news.tiscali.de!news.belwue.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Problems with controlled types, gnatmem thinks handle is leaking memory (long) Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1s73d5wqz8pme.1m22aqftdn6ij.dlg@40tude.net> Date: Mon, 21 Feb 2005 21:54:49 +0100 Message-ID: NNTP-Posting-Date: 21 Feb 2005 21:54:45 MET NNTP-Posting-Host: 1d414dd7.newsread2.arcor-online.net X-Trace: DXC=Nn]1R:\>;oML0\Y_Wg[Z[NQ5U85hF6f;DjW\KbG]kaMHea\9g\;7NmE0aW?Xcf6>QO[6LHn;2LCVNVVa[ZlQni_AdO2c8UW^`\D X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8450 Date: 2005-02-21T21:54:45+01:00 List-Id: On 21 Feb 2005 20:12:34 +0000, Simon Wright wrote: > "Luke A. Guest" writes: > >> On Sun, 20 Feb 2005 19:09:02 +0100, Dmitry A. Kazakov wrote: > >>> In Finalize: I check if Ref_Count = 0 before decrementing and raise >> >> No need to check for the reference count to be 0, as it can never go >> negative and if it does, there's a problem with the code. > > I believe it is possible for an object to be Finalized more than once. In the case of a handle it is not a problem because its Finalize is sort of if pointer /= null then decrement reference count; if reference count = 0 then free object (and pointer is null); else pointer := null; end if; end if; Thus, when called again Finalize would do nothing. >>> if the Ref_Count is zero upon object's finalization. That helps a >>> lot! >> >> I suppose I could raise an exception if the reference count isn't >> zero on finalisation, hmmm...but surely there would be an error in >> the code if that were not the case? Surely it's another example of >> what I mentioned above, it should never go wrong as long as the >> initialize, adjust & finalize subprograms have been implemented >> correctly. > > It isn't a good idea to propagate an exception out of a Finalize > operation (it's a bounded error to do so, 7.6.1(14)). Yes, but here (when the reference count is not zero) it is too late to undertake anything. The exception just signals a fatal error. In this sense it is already a bounded error to get here. It is as bad as Segmentation Fault. The only thing one can do is to abort the program with all its tasks as soon as possible. I raise Program_Error, though it would be nice to have an exception that isn't propagated, but kills the partition at the spot... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de