diff mbox

[Ada] Fix runtime assertion failure in timed selective wait

Message ID 20111013101749.GA17297@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 13, 2011, 10:17 a.m. UTC
This change ensures fixes an improper usage of Defer_Abort where
Defer_Abort_Nestable is meant, that would cause a failed assrtion
if a timed selective accept statement occurs when there already is
a pending call to the accepted entry.

The following program must compile and execute quietly:

with Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;

procedure Call_Then_Accept is
   task Caller is
      entry Start;
   end Caller;

   task Callee is
      entry Start;
      entry With_Body;
   end Callee;

   task body Caller is
   begin
      accept Start do
         null;
      end Start;
      Callee.With_Body;
   end Caller;

   task body Callee is
      Called : Boolean := False;
   begin
      accept Start do
         null;
      end Start;
      select
         delay 10.0;
      or
         accept With_Body do
            Called := True;
         end With_Body;
      end select;
   exception
      when E : others =>
         Put_Line ("Callee: got " & Ada.Exceptions.Exception_Information (E));
   end Callee;

begin
   Caller.Start;
   delay 0.1;
   Callee.Start;
end Call_Then_Accept;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-10-13  Thomas Quinot  <quinot@adacore.com>

	* s-tasren.adb (Timed_Selective_Wait, case
	Accept_Alternative_Selected): Use Defer_Abort_Nestable, since
	we know abortion is already deferred.
diff mbox

Patch

Index: s-tasren.adb
===================================================================
--- s-tasren.adb	(revision 179894)
+++ s-tasren.adb	(working copy)
@@ -1502,7 +1502,7 @@ 
             --  Null_Body. Defer abort until it gets into the accept body.
 
             Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data;
-            Initialization.Defer_Abort (Self_Id);
+            Initialization.Defer_Abort_Nestable (Self_Id);
             STPO.Unlock (Self_Id);
 
          when Accept_Alternative_Completed =>