]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Unsynchronized access to a Boolean in tasking state
authorSteve Baird <baird@adacore.com>
Fri, 14 May 2021 22:03:02 +0000 (15:03 -0700)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 7 Jul 2021 16:23:10 +0000 (16:23 +0000)
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

index f18c76f59e2b26cdd04c2fc8922a90373b51f892..88850c24693c357aca6d0eefc379643ba926dab6 100644 (file)
@@ -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;