* [Ada] Only use alternate stack when needed
@ 2022-05-13 8:07 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-13 8:07 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 323 bytes --]
If we're not going to install a signal handler for SIGSEGV then we do
not need an alternate stack to handle this signal (and e.g. stack
overflows).
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* libgnarl/s-taprop__linux.adb (Initialize): Do not use an
alternate stack if no handler for SEGV is installed.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1718 bytes --]
diff --git a/gcc/ada/libgnarl/s-taprop__linux.adb b/gcc/ada/libgnarl/s-taprop__linux.adb
--- a/gcc/ada/libgnarl/s-taprop__linux.adb
+++ b/gcc/ada/libgnarl/s-taprop__linux.adb
@@ -96,7 +96,7 @@ package body System.Task_Primitives.Operations is
Foreign_Task_Elaborated : aliased Boolean := True;
-- Used to identified fake tasks (i.e., non-Ada Threads)
- Use_Alternate_Stack : constant Boolean := Alternate_Stack_Size /= 0;
+ Use_Alternate_Stack : Boolean := Alternate_Stack_Size /= 0;
-- Whether to use an alternate signal stack for stack overflows
Abort_Handler_Installed : Boolean := False;
@@ -1375,9 +1375,9 @@ package body System.Task_Primitives.Operations is
function State
(Int : System.Interrupt_Management.Interrupt_ID) return Character;
pragma Import (C, State, "__gnat_get_interrupt_state");
- -- Get interrupt state. Defined in a-init.c
- -- The input argument is the interrupt number,
- -- and the result is one of the following:
+ -- Get interrupt state. Defined in init.c.
+ -- The input argument is the interrupt number, and the result is one of
+ -- the following:
Default : constant Character := 's';
-- 'n' this interrupt not set by any Interrupt_State pragma
@@ -1409,6 +1409,12 @@ package body System.Task_Primitives.Operations is
Specific.Initialize (Environment_Task);
+ -- Do not use an alternate stack if no handler for SEGV is installed
+
+ if State (SIGSEGV) = Default then
+ Use_Alternate_Stack := False;
+ end if;
+
if Use_Alternate_Stack then
Environment_Task.Common.Task_Alternate_Stack :=
Alternate_Stack'Address;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-13 8:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 8:07 [Ada] Only use alternate stack when needed Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).