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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.yTvCNOh9TRCAIcX40YItlQ.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Tracing a race condition Date: Sat, 2 Feb 2019 21:52:41 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: yTvCNOh9TRCAIcX40YItlQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:55435 Date: 2019-02-02T21:52:41+01:00 List-Id: On 2019-02-02 21:01, Jere wrote: > I think what is happening is Task A calls a series of code > that eventually causes a call to Release on an object and > so does Task B. When that happens, there is a small chance > of the following situation: > > Task A: Decrement_Count(Object); -- Use_Count goes down to 1 > Task A gives up its time slot > Task B resumes > Task B: Decrement_Count(Object); -- Use_Count goes down to 0 > Task B: if Object.Use_Count > 0 then -- skips this since 0 > ... > Task B: Free(Ptr); -- This free is logically wrong (early) > ... > Task B gives up its time slot > Task A resumes > Task A: if Object.Use_Count > 0 then -- skips this since 0 > ... > Task A: Free(Ptr); -- This free causes the exception (I think) > > That doesn't mean that the #1 scenario isn't also a problem, but > I am still looking at it to verify. In the mean time, is this > a potential race condition in the Release procedure? I seems so. Though Natural is passed by value, its container object is by reference. Thanks for catching it. I am going to fix that. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de