From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Reference counter in smart pointers are not updated properly when used by multiple tasks
Date: Thu, 1 Feb 2018 09:39:23 +0100
Date: 2018-02-01T09:39:23+01:00 [thread overview]
Message-ID: <p4ujnr$320$1@gioia.aioe.org> (raw)
In-Reply-To: a89d76e4-a2b2-4ad9-8816-f3bfe9686930@googlegroups.com
On 01/02/2018 06:52, onox wrote:
> So the smart pointers are not working properly when there are jobs (paired with the same
> smart pointer) being executed by multiple workers.
Depends on the implementation. Surely handling reference counts must be
done in a task-safe manner, e.g. through a protected action. Pragma
Atomic is no help here.
> I'm not sure if this is a bug in my
> own code or whether GNAT is doing something funky in the Finalize procedure.
I never had problems with that.
> Can someone provide some insight?
1. I have two implementations, one with heavy logging/tracing the
actions taken on reference counts.
2. There is gnatmem, which works surprisingly good. Reference-counted
objects are allocated in the pool, so most of bugs are also memory leaks.
3. Controlled objects are tagged and thus passed by reference. It is
important to remember when passing controlled handles/smart pointers
around. A usual schema for dealing with shared linked structures like
graphs is to clone its parts when updated under concurrent access. The
case is detected using the reference count value > n, where n is the
number of "owned" references. That n depends on parameter passing
mechanism, which is, as I said, by-reference.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2018-02-01 8:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 5:52 Reference counter in smart pointers are not updated properly when used by multiple tasks onox
2018-02-01 8:39 ` Dmitry A. Kazakov [this message]
2018-02-01 10:01 ` onox
2018-02-01 10:28 ` onox
2018-02-01 10:51 ` Dmitry A. Kazakov
2018-02-01 10:57 ` Dmitry A. Kazakov
2018-02-01 8:41 ` Simon Wright
2018-02-01 14:48 ` Jeffrey R. Carter
2018-02-01 19:37 ` onox
2018-02-01 20:12 ` Jeffrey R. Carter
2018-02-02 0:09 ` Randy Brukardt
2018-02-01 19:04 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox