OSDN Git Service

2009-04-24 Arnaud Charlet <charlet@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Apr 2009 10:02:16 +0000 (10:02 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Apr 2009 10:02:16 +0000 (10:02 +0000)
* s-tassta.adb (Create_Task): Fix violation of locking rule.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146685 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/s-tassta.adb

index ae01f1c..e6b69b3 100644 (file)
@@ -1,3 +1,7 @@
+2009-04-24  Arnaud Charlet  <charlet@adacore.com>
+
+       * s-tassta.adb (Create_Task): Fix violation of locking rule.
+
 2009-04-24  Emmanuel Briot  <briot@adacore.com>
 
        * prj.adb, prj.ads, prj-nmsc.adb, prj-env.adb (Language_Index): renamed
index 62aee27..76e3740 100644 (file)
@@ -621,14 +621,18 @@ package body System.Tasking.Stages is
          T.Common.Task_Image_Len := Len;
       end if;
 
+      Unlock (Self_ID);
+      Unlock_RTS;
+
+      --  Note: we should not call 'new' while holding locks since new
+      --  may use locks (e.g. RTS_Lock under Windows) itself and cause a
+      --  deadlock.
+
       if Build_Entry_Names then
          T.Entry_Names :=
            new Entry_Names_Array (1 .. Entry_Index (Num_Entries));
       end if;
 
-      Unlock (Self_ID);
-      Unlock_RTS;
-
       --  Create TSD as early as possible in the creation of a task, since it
       --  may be used by the operation of Ada code within the task.