comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: Reference counting and idempotent finalize
Date: Thu, 12 Sep 2013 05:34:53 +0000 (UTC)
Date: 2013-09-12T05:34:53+00:00	[thread overview]
Message-ID: <slrnl32kjd.1lme.lithiumcat@sigil.instinctive.eu> (raw)
In-Reply-To: 5rbmj2y8ml2b$.e0ygtir1g3mt$.dlg@40tude.net

On 2013-09-11, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
> You could make an alternative version for debug scenario which keeps track
> of all changes of the reference count dumping them on errors. GNAT stack
> trace is handy for that. Do not trust reference counting, it is an endless
> source of many hideous errors even if the implementation of is correct.

Would you please elaborate on why reference counting shouldn't be
trusted? What dangers am I brazingly exposing myself to?

> Tracing for the latest exception when in Finalize (GNAT functionality) is
> extremely helpful as well, because upon error propagation you get a
> snowball of cascading exceptions hiding the original problem. Always kill
> any exceptions in Finalize and do an emergency tracing in the handler.
>
> Yet another version is likely needed for tasking, that is when the
> reference objects are used concurrently, so that the reference count is
> updated concurrently. You will need a protected object to handle increments
> and decrements and careful design preventing concurrent increments when the
> count reached 0.

All these refinements are way beyond the scope a basic roll-my-own
implementation. If I needed such complexity I wouldn't have tried to
implement it without having thoroughly checked that there is no suitable
implementation already available.

I have roughly the same heuristic for concurrent stuff and for proper
fault recovery as I have for cryptography: never try to code it at home
unless it really does not exist elsewhere yet.

  reply	other threads:[~2013-09-12  5:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 10:45 Reference counting and idempotent finalize Natasha Kerensikova
2013-09-11 11:21 ` AdaMagica
2013-09-11 12:12 ` Dmitry A. Kazakov
2013-09-12  5:34   ` Natasha Kerensikova [this message]
2013-09-12  7:33     ` Dmitry A. Kazakov
2013-09-11 12:16 ` Dmitry A. Kazakov
2013-09-12  4:53   ` Natasha Kerensikova
2013-09-11 12:21 ` Jeffrey R. Carter
2013-09-11 20:03   ` Simon Wright
2013-09-12  4:46     ` Natasha Kerensikova
2013-09-12  5:05   ` Natasha Kerensikova
2013-09-12  7:54     ` Dmitry A. Kazakov
2013-09-12 17:03     ` Jeffrey R. Carter
2013-09-11 13:50 ` Pascal Obry
2013-09-12  4:56   ` Natasha Kerensikova
2013-09-12 14:33     ` Simon Wright
2013-09-12 15:40     ` Pascal Obry
2013-09-12 10:23 ` sbelmont700
2013-09-30  6:25 ` Natasha Kerensikova
2013-09-30 10:02   ` AdaMagica
2013-10-01  6:22     ` Natasha Kerensikova
replies disabled

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