From 4f152b890fe63789857ba9d6f5b9629eb46ab418 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 30 Jan 2015 02:25:42 +0100 Subject: grt: fix protected object lock during elaboration. --- src/grt/grt-processes.adb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/grt') diff --git a/src/grt/grt-processes.adb b/src/grt/grt-processes.adb index 0a905d831..4a124e689 100644 --- a/src/grt/grt-processes.adb +++ b/src/grt/grt-processes.adb @@ -564,14 +564,20 @@ package body Grt.Processes is is Lock : constant Object_Lock_Acc := To_Lock_Acc_Acc (Obj).all; begin - if Lock.Process = null then - if Lock.Count /= 0 then + if Lock.Count = 0 then + -- Protected object not locked. + if Lock.Process /= null then + -- Sanity check failed: count must be 0. Internal_Error ("protected_enter"); end if; + + -- Note: during elaboration, there is no current process. Lock.Process := Get_Current_Process; Lock.Count := 1; else + -- Protected object already locked. if Lock.Process /= Get_Current_Process then + -- Should be locked by the current process. Internal_Error ("protected_enter(2)"); end if; Lock.Count := Lock.Count + 1; -- cgit v1.2.3