[Ada] spurious stack-checking failures on arm-vxworks
Arnaud Charlet
charlet@adacore.com
Tue Oct 31 20:00:00 GMT 2006
Manually tested on arm-vxworks
Tested on i686-linux, committed on trunk.
To retrieve information on the stack area for the current task on VxWorks,
we use the taskInfoGet service and pass a pointer to a locally declared
task descriptor to fill. To offer visibility on the fields of interest for
our purposes, and for access efficieny reasons, an Ada version of the
descriptor type is locally declared as well.
The local task descriptor type layout should match what the VxWorks service
expects, and it was fine for Tornado versions up to 2.0. In Tornado 2.2, an
extra "events" field is part of the VxWorks task descriptor, and we had
not adjusted our binding declaration accordingly so were passing a pointer
to too short an object. This resulted in local frame memory clobbering with
various nasty effects, and spurious stack-checking failures as a visible
outcome.
The fix applied here consists in updating the task descriptor type to
include the missing field.
Any source program would do as a testcase, as long as it is compiled
with -fstack-check to trigger calls to the faulty run-time library routine.
2006-10-31 Olivier Hainque <hainque@adacore.com>
* s-stchop.ads: make this unit preelaborate. This is desirable in
general and made mandatory by the use of this unit by s-taprop which
is itself preelaborate.
* s-stchop-vxworks.adb (Set_Stack_Info, Task_Descriptor type): Add
Td_Events component.
-------------- next part --------------
Index: s-stchop.ads
===================================================================
--- s-stchop.ads (revision 118179)
+++ s-stchop.ads (working copy)
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1999-2005 Free Software Foundation, Inc. --
+-- Copyright (C) 1999-2006, 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- --
@@ -43,6 +43,8 @@ pragma Polling (Off);
-- checking operations. It causes infinite loops and other problems.
package System.Stack_Checking.Operations is
+ pragma Preelaborate;
+
procedure Update_Stack_Cache (Stack : Stack_Access);
-- Set the stack cache for the current task. Note that this is only
-- for optimization purposes, nothing can be assumed about the
Index: s-stchop-vxworks.adb
===================================================================
--- s-stchop-vxworks.adb (revision 118179)
+++ s-stchop-vxworks.adb (working copy)
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1999-2005 Free Software Foundation, Inc. --
+-- Copyright (C) 1999-2006 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- --
@@ -104,6 +104,10 @@ package body System.Stack_Checking.Opera
is
-- Task descriptor that is handled internally by the VxWorks kernel
+
+ type Td_Events_Storage is array (1 .. 4) of Interfaces.C.int;
+ pragma Convention (C, Td_Events_Storage);
+
type Task_Descriptor is record
T_Id : Interfaces.C.int; -- task identifier
Td_Name : System.Address; -- task name
@@ -121,6 +125,7 @@ package body System.Stack_Checking.Opera
Td_StackMargin : Interfaces.C.int; -- current stack margin in bytes
Td_ErrorStatus : Interfaces.C.int; -- most recent task error status
Td_Delay : Interfaces.C.int; -- delay/timeout ticks
+ Td_Events : Td_Events_Storage; -- task events, post t2.0
end record;
pragma Convention (C, Task_Descriptor);
More information about the Gcc-patches
mailing list