[Ada] Fix deadlock under Windows
Arnaud Charlet
charlet@adacore.com
Fri Apr 24 10:26:00 GMT 2009
The change to implement support for task entry images introduced a hard to
detect/identify deadlock under Windows where the lock associated with Self
should not be held when trying call new. The locking rule is stated in
s-taskin.ads.
Tested on x86_64-pc-linux-gnu, committed on trunk
2009-04-24 Arnaud Charlet <charlet@adacore.com>
* s-tassta.adb (Create_Task): Fix violation of locking rule.
-------------- next part --------------
Index: s-tassta.adb
===================================================================
--- s-tassta.adb (revision 146680)
+++ s-tassta.adb (working copy)
@@ -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.
More information about the Gcc-patches
mailing list