Patchwork [Ada] Fix PR ada/43993

login
register
mail settings
Submitter Arnaud Charlet
Date Sept. 10, 2010, 9:45 a.m.
Message ID <20100910094552.GA30202@adacore.com>
Download mbox | patch
Permalink /patch/64364/
State New
Headers show

Comments

Arnaud Charlet - Sept. 10, 2010, 9:45 a.m.
As explained in the PR, in case of foreign (non Ada) threads, the run time
would read an uninitialized variable, fixed by this patch.

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

2010-09-10  Arnaud Charlet  <charlet@adacore.com>

	* s-taprop-linux.adb, s-taskin.ads (Task_Alternate_Stack): Default
	initialize to Null_Address.
	(Enter_Task): Do not set up an alternate stack for foreign threads.

Patch

Index: s-taprop-linux.adb
===================================================================
--- s-taprop-linux.adb	(revision 164000)
+++ s-taprop-linux.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                  B o d y                                 --
 --                                                                          --
---         Copyright (C) 1992-2009, Free Software Foundation, Inc.          --
+--         Copyright (C) 1992-2010, Free Software Foundation, Inc.          --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -717,7 +717,9 @@  package body System.Task_Primitives.Oper
 
       Specific.Set (Self_ID);
 
-      if Use_Alternate_Stack then
+      if Use_Alternate_Stack
+        and then Self_ID.Common.Task_Alternate_Stack /= Null_Address
+      then
          declare
             Stack  : aliased stack_t;
             Result : Interfaces.C.int;
Index: s-taskin.ads
===================================================================
--- s-taskin.ads	(revision 164070)
+++ s-taskin.ads	(working copy)
@@ -523,7 +523,7 @@  package System.Tasking is
       --  Activator writes it, once, before Self starts executing. Thereafter,
       --  Self only reads it.
 
-      Task_Alternate_Stack : System.Address;
+      Task_Alternate_Stack : System.Address := System.Null_Address;
       --  The address of the alternate signal stack for this task, if any
       --
       --  Protection: Only accessed by Self