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 Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Using Class wide types as factories, is this legit? Date: Tue, 23 Sep 2014 21:28:55 +0200 Organization: cbb software GmbH Message-ID: <1ow7xs34a7j7z.1f0806cgaoh7r$.dlg@40tude.net> References: <4b9c517f-9c78-44f5-bda1-8e7647f06851@googlegroups.com> <14aahny7n1xxq.12aqg1nr0sro0$.dlg@40tude.net> <4a7d6542-d4c1-4d79-8def-d4b74e06dacd@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: ZB2Fb2q1fa4xpMpNKFqV6Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:189112 Date: 2014-09-23T21:28:55+02:00 List-Id: On Tue, 23 Sep 2014 01:21:58 -0700 (PDT), David Botton wrote: >> It is hard to say without seeing Initialize, Finalize and Adjust. I would >> guess that Adjust is wrong, e.g. not making a deep copy of the things >> killed in Finalize, which may lead to deallocating these twice in the first >> variant of your code. > > There is no adjust or finalize. Initialize looks like this: > > procedure Initialize (Object : in out Active_Record) is > use Gnoga.Server.Database; > begin > if Object.Connection = null then > raise Connection_Error; > end if; > > Object.Fields := > Object.Connection.List_Fields_Of_Table > (Object.Table_Name.all); > end Initialize; You should check controlled components as well. For debugging, create a controlled type Foo with Initialize, Finalize, Adjust printing some texts. Insert a member of this type at different places of the record to determine which component causes crash. Type's Finalize is called before finalization of components, type's Initialize is called after initialization of components. Use GNAT.Most_Recent_Exception to determine of the problem is secondary happens upon exception propagation. Very often finalization issues hide the actual problem. Use GNAT.Exception_Traces to find exceptions that silently kill the program. Regarding your design. The rule of thumb is that controlled and other copyable objects shall not have access discriminants. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de