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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ee06257af909a235 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: Finalization of static package variables References: <4640f20b$1@news.upm.es> <1178723724.958486.24820@u30g2000hsc.googlegroups.com> From: Markus E Leypold Organization: N/A Date: Wed, 09 May 2007 18:01:32 +0200 Message-ID: User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:uA1d/chFuwoZnayzrvwky2UV6EU= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 88.72.195.162 X-Trace: news.arcor-ip.de 1178725984 88.72.195.162 (9 May 2007 17:53:04 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news1.google.com!news3.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news1.google.com comp.lang.ada:15703 Date: 2007-05-09T18:01:32+02:00 List-Id: Adam Beneschan writes: > On May 9, 1:20 am, Stephen Leake > wrote: >> Manuel Collado writes: >> > Variables declared in the global scope of a package body seem not to >> > be finalized automatically at the end of the whole program (using GNAT >> > 3.15p on WindowsXP). >> >> Is there some reason you are not using a more current version of GNAT? >> >> > If some of these variables contain certain GUI stuff, the program >> > remains as a zombie process after the main procedure termination. >> >> Technically, that cannot be true; the "main procedure" is the >> "environment task", and it does not "terminate" (in the Ada definition >> of that word) until all of the tasks it has spawned have "terminated". >> >> I think that what you are saying is that there are some tasks that >> have not terminated when the main procedure is ready to terminate, and >> that in fact those tasks never terminate. > > Except that Manuel never said he was using tasks. I'm envisioning > that he probably has a controlled object whose initialization causes > some Windows process to be spawned (either directly or via some > function in some other GUI library), and finalization causes the > process to be terminated. > > >> If the type of the variable is derived from >> Ada.Finalization.Controlled or Limited_Controlled, it will be >> finalized when it goes out of scope. Otherwise, it won't be. >> >> However, a static package variable never goes out of scope, so that is >> no help. > > No, I believe that all objects, including static package variables > *and* including allocated objects that have not yet been deallocated, > are supposed to be finalized when the environment task completes. > 10.2(25), 7.6.1(10). Absolutely right. With Gnat, though, that isn't the case if the process is terminated by an external signal, e.g. SIGINT from keyboard or the ^C handler in the windows console. I wonder wether it is that which is puzzling the OP. Regards -- Markus