* [Linux-ia64] sigaltstack not working
@ 2001-09-17 14:12 Andreas Schwab
2001-09-17 15:07 ` David Mosberger
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Andreas Schwab @ 2001-09-17 14:12 UTC (permalink / raw)
To: linux-ia64
[-- Attachment #1: Type: text/plain, Size: 416 bytes --]
The appended program isn't working as expected. As soon as the stack
limit is reached it hangs without actually executing the signal handler.
Andreas.
--
Andreas Schwab "And now for something
Andreas.Schwab@suse.de completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
[-- Attachment #2: sigaltstack.c --]
[-- Type: text/plain, Size: 1206 bytes --]
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/types.h>
#include <sys/resource.h>
sigjmp_buf mainloop;
volatile int pass = 0;
void
stackoverflow_handler (int sig)
{
pass++;
printf ("Stack overflow %d caught.\n", pass);
siglongjmp (mainloop, pass);
}
int
recurse (int n)
{
printf ("%p\n", &n);
if (n >= 0)
return n + recurse (n + 1);
else
return 0;
}
int
main ()
{
char mystack[16384];
struct rlimit rl;
stack_t ss;
struct sigaction action;
rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */
setrlimit (RLIMIT_STACK, &rl);
ss.ss_sp = mystack;
ss.ss_size = sizeof (mystack);
ss.ss_flags = 0;
if (sigaltstack (&ss, (stack_t *) 0) < 0)
exit (0);
action.sa_handler = stackoverflow_handler;
action.sa_flags = SA_ONSTACK;
sigemptyset (&action.sa_mask);
if (sigaction (SIGSEGV, &action, 0) < 0)
exit (0);
switch (sigsetjmp (mainloop, 1))
{
case 0:
case 1:
printf ("Starting recursion pass %d.\n", pass + 1);
recurse (0);
printf ("no endless recursion?!\n");
exit (1);
case 2:
printf ("Test passed.\n");
exit (0);
default:
abort ();
}
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Linux-ia64] sigaltstack not working
2001-09-17 14:12 [Linux-ia64] sigaltstack not working Andreas Schwab
@ 2001-09-17 15:07 ` David Mosberger
2001-09-17 15:27 ` Andreas Schwab
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: David Mosberger @ 2001-09-17 15:07 UTC (permalink / raw)
To: linux-ia64
>>>>> On 17 Sep 2001 16:12:34 +0200, Andreas Schwab <schwab@suse.de> said:
Andreas> The appended program isn't working as expected. As soon as
Andreas> the stack limit is reached it hangs without actually
Andreas> executing the signal handler.
I'm aware of this problem and it's on my todo list, but I'm not sure
exactly when I'll find time to fix it. Did you encounter this in a
real program or just with a test program?
--david
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Linux-ia64] sigaltstack not working
2001-09-17 14:12 [Linux-ia64] sigaltstack not working Andreas Schwab
2001-09-17 15:07 ` David Mosberger
@ 2001-09-17 15:27 ` Andreas Schwab
2001-09-17 15:33 ` David Mosberger
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2001-09-17 15:27 UTC (permalink / raw)
To: linux-ia64
David Mosberger <davidm@hpl.hp.com> writes:
|> >>>>> On 17 Sep 2001 16:12:34 +0200, Andreas Schwab <schwab@suse.de> said:
|>
|> Andreas> The appended program isn't working as expected. As soon as
|> Andreas> the stack limit is reached it hangs without actually
|> Andreas> executing the signal handler.
|>
|> I'm aware of this problem and it's on my todo list, but I'm not sure
|> exactly when I'll find time to fix it. Did you encounter this in a
|> real program or just with a test program?
It is derived from a test program in clisp 2.26 that verifies that
catching stack overflow works. That test is even worse, you can only kill
it with SIGKILL.
Andreas.
--
Andreas Schwab "And now for something
Andreas.Schwab@suse.de completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Linux-ia64] sigaltstack not working
2001-09-17 14:12 [Linux-ia64] sigaltstack not working Andreas Schwab
2001-09-17 15:07 ` David Mosberger
2001-09-17 15:27 ` Andreas Schwab
@ 2001-09-17 15:33 ` David Mosberger
2001-09-18 5:53 ` David Mosberger
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: David Mosberger @ 2001-09-17 15:33 UTC (permalink / raw)
To: linux-ia64
>>>>> On 17 Sep 2001 17:27:01 +0200, Andreas Schwab <schwab@suse.de> said:
Andreas> It is derived from a test program in clisp 2.26 that
Andreas> verifies that catching stack overflow works. That test is
Andreas> even worse, you can only kill it with SIGKILL.
OK, that makes sense. I'll look into it asap.
On an unrelated note: I fixed the ia32 subsystem so it can run
realplay v8, mozilla v0.94 (including Flash plug-in), and OpenOffice
638, among others. If someone has an urgent need for this, I can make
an interim patch availabe. Otherwise, it will show up in 2.4.10
(which presumably will happen soon).
--david
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Linux-ia64] sigaltstack not working
2001-09-17 14:12 [Linux-ia64] sigaltstack not working Andreas Schwab
` (2 preceding siblings ...)
2001-09-17 15:33 ` David Mosberger
@ 2001-09-18 5:53 ` David Mosberger
2001-09-18 8:50 ` Jes Sorensen
2001-09-18 9:21 ` Andreas Schwab
5 siblings, 0 replies; 7+ messages in thread
From: David Mosberger @ 2001-09-18 5:53 UTC (permalink / raw)
To: linux-ia64
>>>>> On 17 Sep 2001 16:12:34 +0200, Andreas Schwab <schwab@suse.de> said:
Andreas> The appended program isn't working as expected. As soon as
Andreas> the stack limit is reached it hangs without actually
Andreas> executing the signal handler.
Below is a first draft to fix this problem. With the patch applied,
the test program works fine. I call it a "first draft" since it
hasn't received a whole lot of testing yet. I'd appreciate it if
others could help with testing. If you find any bugs, please let me
know (and if it works, I appreciate a note, too ;-).
For completeness, it is also necessary to update the MINSIGSTKSZ and
SIGSTKSZ macros in include/asm-ia64/signal.h. I'm using the following
values now:
#define MINSIGSTKSZ 131027 /* min. stack size for sigaltstack() */
#define SIGSTKSZ 262144 /* default stack size for sigaltstack() */
The old values were far too small. The new values are somewhat
largish but it's better to be safe here as the values really can't be
increased without breaking binary compatibility. Thanks to Rafael
Hernandez for finding this!
Jes, will you make the corresponding changes to sigcontext.h and
signal.h in libc?
Thanks,
--david
--- lia64-kdb/include/asm-ia64/sigcontext.h~ Thu Aug 16 11:04:37 2001
+++ lia64-kdb/include/asm-ia64/sigcontext.h Mon Sep 17 18:16:08 2001
@@ -40,7 +40,8 @@
unsigned long sc_gr[32]; /* general registers (static partition) */
struct ia64_fpreg sc_fr[128]; /* floating-point registers */
- unsigned long sc_rsvd[16]; /* reserved for future use */
+ unsigned long sc_loadrs;
+ unsigned long sc_rsvd[15]; /* reserved for future use */
/*
* The mask must come last so we can increase _NSIG_WORDS
--- lia64-kdb/arch/ia64/tools/print_offsets.c~ Mon Sep 10 10:27:11 2001
+++ lia64-kdb/arch/ia64/tools/print_offsets.c Mon Sep 17 18:16:26 2001
@@ -165,6 +165,7 @@
{ "IA64_SIGCONTEXT_FR6_OFFSET", offsetof (struct sigcontext, sc_fr[6]) },
{ "IA64_SIGCONTEXT_PR_OFFSET", offsetof (struct sigcontext, sc_pr) },
{ "IA64_SIGCONTEXT_R12_OFFSET", offsetof (struct sigcontext, sc_gr[12]) },
+ { "IA64_SIGCONTEXT_LOADRS_OFFSET", offsetof (struct sigcontext, sc_loadrs) },
{ "IA64_SIGFRAME_ARG0_OFFSET", offsetof (struct sigframe, arg0) },
{ "IA64_SIGFRAME_ARG1_OFFSET", offsetof (struct sigframe, arg1) },
{ "IA64_SIGFRAME_ARG2_OFFSET", offsetof (struct sigframe, arg2) },
--- lia64-kdb/arch/ia64/kernel/gate.S~ Mon Sep 17 18:54:41 2001
+++ lia64-kdb/arch/ia64/kernel/gate.S Mon Sep 17 21:18:39 2001
@@ -74,7 +74,8 @@
.vframesp SP_OFF+SIGCONTEXT_OFF
.body
- .prologue
+ .label_state 1
+
adds base0=SIGHANDLER_OFF,sp
adds base1=RBS_BASE_OFF,sp
br.call.sptk.many rp\x1f
@@ -156,6 +157,8 @@
mov r15=__NR_rt_sigreturn
break __BREAK_SYSCALL
+ .body
+ .copy_state 1
setup_rbs:
mov ar.rsc=0 // put RSE into enforced lazy mode
;;
@@ -180,22 +183,25 @@
mov ar.rsc=0xf // set RSE into eager mode, pl 3
br.cond.sptk back_from_setup_rbs
+ .prologue
+ .copy_state 1
+ .spillsp ar.rnat, RNAT_OFF+SIGCONTEXT_OFF
+ .body
restore_rbs:
alloc r2=ar.pfs,0,0,0,0 // alloc null frame
adds r16=(LOADRS_OFF+SIGCONTEXT_OFF),sp
;;
ld8 r14=[r16]
+ adds r16=(RNAT_OFF+SIGCONTEXT_OFF),sp
;;
mov ar.rsc=r14 // put RSE into enforced lazy mode
+ ld8 r14=[r16] // get new rnat
;;
loadrs // restore dirty partition
-
- adds r16=(RNAT_OFF+SIGCONTEXT_OFF),sp
;;
- ld8 r14=[r16] // get new rnat
- mov ar.bspstore=r15 // set old register backing store area
+ mov ar.bspstore=r15 // switch back to old register backing store area
;;
- mov ar.rnat=r14 // establish new rnat
+ mov ar.rnat=r14 // restore RNaT
mov ar.rsc=0xf // (will be restored later on from sc_ar_rsc)
// invala not necessary as that will happen when returning to user-mode
br.cond.sptk back_from_restore_rbs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Linux-ia64] sigaltstack not working
2001-09-17 14:12 [Linux-ia64] sigaltstack not working Andreas Schwab
` (3 preceding siblings ...)
2001-09-18 5:53 ` David Mosberger
@ 2001-09-18 8:50 ` Jes Sorensen
2001-09-18 9:21 ` Andreas Schwab
5 siblings, 0 replies; 7+ messages in thread
From: Jes Sorensen @ 2001-09-18 8:50 UTC (permalink / raw)
To: linux-ia64
>>>>> "David" = David Mosberger <davidm@hpl.hp.com> writes:
David> Jes, will you make the corresponding changes to sigcontext.h
David> and signal.h in libc?
Sure, I'll look at it when I get back to Canada, hopefully next week.
Cheers
Jes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Linux-ia64] sigaltstack not working
2001-09-17 14:12 [Linux-ia64] sigaltstack not working Andreas Schwab
` (4 preceding siblings ...)
2001-09-18 8:50 ` Jes Sorensen
@ 2001-09-18 9:21 ` Andreas Schwab
5 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2001-09-18 9:21 UTC (permalink / raw)
To: linux-ia64
David Mosberger <davidm@hpl.hp.com> writes:
|> --- lia64-kdb/arch/ia64/kernel/gate.S~ Mon Sep 17 18:54:41 2001
|> +++ lia64-kdb/arch/ia64/kernel/gate.S Mon Sep 17 21:18:39 2001
This does not apply on top of the 2.4.9-ia64-010820 patch.
Andreas.
--
Andreas Schwab "And now for something
Andreas.Schwab@suse.de completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-09-18 9:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-17 14:12 [Linux-ia64] sigaltstack not working Andreas Schwab
2001-09-17 15:07 ` David Mosberger
2001-09-17 15:27 ` Andreas Schwab
2001-09-17 15:33 ` David Mosberger
2001-09-18 5:53 ` David Mosberger
2001-09-18 8:50 ` Jes Sorensen
2001-09-18 9:21 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox