From: Steve Baird Date: Fri, 14 May 2021 22:03:02 +0000 (-0700) Subject: [Ada] Unsynchronized access to a Boolean in tasking state X-Git-Tag: basepoints/gcc-13~6212 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dbe0e11eb75e52885a0f6894a8d3da770f87ca0;p=thirdparty%2Fgcc.git [Ada] Unsynchronized access to a Boolean in tasking state gcc/ada/ * libgnarl/s-tassta.adb (Free_Task): Acquire the Task_Lock before, rather than after, querying the task's Terminated flag. Add a corresponding Task_Unlock call. --- diff --git a/gcc/ada/libgnarl/s-tassta.adb b/gcc/ada/libgnarl/s-tassta.adb index f18c76f59e2b..88850c24693c 100644 --- a/gcc/ada/libgnarl/s-tassta.adb +++ b/gcc/ada/libgnarl/s-tassta.adb @@ -910,12 +910,12 @@ package body System.Tasking.Stages is Self_Id : constant Task_Id := Self; begin + Initialization.Task_Lock (Self_Id); + if T.Common.State = Terminated then -- It is not safe to call Abort_Defer or Write_Lock at this stage - Initialization.Task_Lock (Self_Id); - Lock_RTS; Initialization.Finalize_Attributes (T); Initialization.Remove_From_All_Tasks_List (T); @@ -930,6 +930,7 @@ package body System.Tasking.Stages is -- upon termination. T.Free_On_Termination := True; + Initialization.Task_Unlock (Self_Id); end if; end Free_Task;