From 0dbe0e11eb75e52885a0f6894a8d3da770f87ca0 Mon Sep 17 00:00:00 2001 From: Steve Baird Date: Fri, 14 May 2021 15:03:02 -0700 Subject: [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. --- gcc/ada/libgnarl/s-tassta.adb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/libgnarl/s-tassta.adb b/gcc/ada/libgnarl/s-tassta.adb index f18c76f..88850c2 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; -- cgit v1.1