public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2101] [Ada] Unsynchronized access to a Boolean in tasking state
@ 2021-07-07 16:24 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-07 16:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0dbe0e11eb75e52885a0f6894a8d3da770f87ca0

commit r12-2101-g0dbe0e11eb75e52885a0f6894a8d3da770f87ca0
Author: Steve Baird <baird@adacore.com>
Date:   Fri May 14 15:03:02 2021 -0700

    [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:
---
 gcc/ada/libgnarl/s-tassta.adb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/libgnarl/s-tassta.adb b/gcc/ada/libgnarl/s-tassta.adb
index f18c76f59e2..88850c24693 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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-07 16:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 16:24 [gcc r12-2101] [Ada] Unsynchronized access to a Boolean in tasking state Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).