This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] improve stack-checking on tru64


Manually tested on Tru64.
Tested on i686-linux. Committed on mainline.

This enables stack checking support on Alpha/Tru64 in multi-threaded
configuration.  The difficulty is that Tru64 allocates an overflow
warning area right above the overflow guard area (Yellow Zone and
Red Zone respectively) and, as soon as the Yellow Zone is touched,
a DEC exception is raised.  Since GNAT doesn't know the first thing
about DEC exceptions, it is not caught and terminates the thread.
The approach is the following: by using a low-level interface described
in /usr/include/pthread.h, it retrieves the Thread Environment Block
address, uses it to obtain the addresses of the Yellow Zone and the Red
Zone (they are fixed for non-primary threads as the stack size is fixed)
and, if they are not equal, it creates a secondary Red Zone right above
the Yellow Zone by sticking a write-protected page there.

Code such as the following used to trigger errors:

procedure P is
   task T;
   task body T is
      procedure Run (Level : Natural) is
         Storage : String (1..1000) := (others => 'A');
      begin
         Run (Level + 1);
      end;
   begin
      Run (0);
   end T;
begin
   null;
end P;

2005-03-08  Eric Botcazou  <ebotcazou@adacore.com>

	* s-osinte-tru64.ads, s-osinte-tru64.adb (Get_Stack_Base): New function
	(Hide_Yellow_Zone): New procedure to hide the Yellow Zone of the
	calling thread.
	(Stack_Base_Available): New flag.
	(Get_Page_Size): New overloaded functions imported from C.
	(PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC, PROT_ALL,
	PROT_ON, PROT_OFF): New constants.
	(mprotect): New function imported from C.
	(pthread_teb_t): New record type.

	* s-taprop-tru64.adb: (Enter_Task): Invoke Hide_Yellow_Zone.
	(Create_Task): Account for the Yellow Zone and the guard page.

Attachment: difs.2
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]