]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix problematic secondary stack management in protected entry
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 23 Aug 2023 16:35:59 +0000 (18:35 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 5 Sep 2023 11:05:16 +0000 (13:05 +0200)
The secondary stack mark goes formally out of scope before the finalizer
reads it to reclaim the storage.

gcc/ada/

* exp_ch9.adb (Build_Protected_Entry): Move the At_End procedure
from the entry body to the inner block statement.

gcc/ada/exp_ch9.adb

index b0e3632b8c83166978024ec0287a4ba5b642dbd5..5dcd890c33cdcf241d4c4b9dbeb24f2aa0040b6b 100644 (file)
@@ -3457,6 +3457,7 @@ package body Exp_Ch9 is
       Set_Uses_Sec_Stack (Block_Id, Uses_Sec_Stack (Corresponding_Spec (N)));
 
       Reset_Scopes_To (First (Bod_Stmts), Block_Id);
+      Set_At_End_Proc (First (Bod_Stmts), At_End_Proc (N));
 
       case Corresponding_Runtime_Package (Pid) is
          when System_Tasking_Protected_Objects_Entries =>
@@ -3553,7 +3554,6 @@ package body Exp_Ch9 is
          --  Establish link between subprogram body and source entry body
 
          Set_Corresponding_Entry_Body (Proc_Body, N);
-         Set_At_End_Proc (Proc_Body, At_End_Proc (N));
 
          Reset_Scopes_To (Proc_Body, Protected_Body_Subprogram (Ent));
          return Proc_Body;