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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.172.102 with SMTP id m38mr6076501iti.36.1517479282103; Thu, 01 Feb 2018 02:01:22 -0800 (PST) X-Received: by 10.157.87.132 with SMTP id q4mr192978oth.2.1517479282018; Thu, 01 Feb 2018 02:01:22 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!g80no176187itg.0!news-out.google.com!k194ni768itb.0!nntp.google.com!g80no176185itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 1 Feb 2018 02:01:21 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=80.114.173.191; posting-account=BtkjvAoAAADwEquGb07eykXfyiDMOxfl NNTP-Posting-Host: 80.114.173.191 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <634ea4dc-af9e-46d2-815b-af5a3aa2f6cd@googlegroups.com> Subject: Re: Reference counter in smart pointers are not updated properly when used by multiple tasks From: onox Injection-Date: Thu, 01 Feb 2018 10:01:22 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Body-CRC: 3694465440 X-Received-Bytes: 1899 Xref: reader02.eternal-september.org comp.lang.ada:50245 Date: 2018-02-01T02:01:21-08:00 List-Id: On Thursday, February 1, 2018 at 9:39:24 AM UTC+1, Dmitry A. Kazakov wrote: > 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. You're right Dimitry, using a protected object instead fixes the problem. But I do not understand why __sync_sub_and_fetch_4 is not sufficient. Could you explain?