Bruno Haible <bruno <at> clisp.org> writes: > > Here's the minimal patch needed to CVS libsigsegv to expose the bug, as > > well as work around it for Irix 5.3. > > Nice work! I'm applying this only slightly modified version. > - In the configuration test, keep room to both sides of the ss_sp value. > On IRIX, we don't want the test to crash. We want it to exit(1) reasonably.
We need to do this consistently, then. The subsequent configure check (whether longjmp works from a stack overflow handler) is needlessly falling foul of the Irix sigaltstack bug. 2008-09-23 Eric Blake <[EMAIL PROTECTED]> Use 2 * SIGSTKSZ consistently in m4 checks. * m4/sigaltstack.m4 (SV_SIGALTSTACK): Work around Irix sigaltstack bug. * m4/sigaltstack-longjmp.m4 (SV_TRY_LEAVE_HANDLER_LONGJMP): Likewise. * m4/sigaltstack-siglongjmp.m4 (SV_TRY_LEAVE_HANDLER_SIGLONGJMP): Likewise. Index: m4/sigaltstack-longjmp.m4 =================================================================== RCS file: /sources/libsigsegv/libsigsegv/m4/sigaltstack-longjmp.m4,v retrieving revision 1.7 diff -u -p -r1.7 sigaltstack-longjmp.m4 --- m4/sigaltstack-longjmp.m4 24 Aug 2008 20:55:16 -0000 1.7 +++ m4/sigaltstack-longjmp.m4 23 Sep 2008 14:13:21 -0000 @@ -1,4 +1,4 @@ -# sigaltstack-longjmp.m4 serial 5 (libsigsegv-2.6) +# sigaltstack-longjmp.m4 serial 6 (libsigsegv-2.6) dnl Copyright (C) 2002-2003, 2006, 2008 Bruno Haible <[EMAIL PROTECTED]> dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General @@ -53,7 +53,7 @@ int recurse (volatile int n) } int main () { - char mystack[SIGSTKSZ]; + char mystack[2 * SIGSTKSZ]; stack_t altstack; struct sigaction action; sigset_t emptyset; @@ -65,9 +65,10 @@ int main () rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */ setrlimit (RLIMIT_STACK, &rl); #endif - /* Install the alternate stack. */ - altstack.ss_sp = mystack; - altstack.ss_size = sizeof (mystack); + /* Install the alternate stack. Use midpoint to work around Irix + sigaltstack bug. */ + altstack.ss_sp = mystack + SIGSTKSZ; + altstack.ss_size = SIGSTKSZ; altstack.ss_flags = 0; /* no SS_DISABLE */ if (sigaltstack (&altstack, NULL) < 0) exit (1); Index: m4/sigaltstack-siglongjmp.m4 =================================================================== RCS file: /sources/libsigsegv/libsigsegv/m4/sigaltstack-siglongjmp.m4,v retrieving revision 1.7 diff -u -p -r1.7 sigaltstack-siglongjmp.m4 --- m4/sigaltstack-siglongjmp.m4 24 Aug 2008 20:55:16 -0000 1.7 +++ m4/sigaltstack-siglongjmp.m4 23 Sep 2008 14:13:21 -0000 @@ -1,4 +1,4 @@ -# sigaltstack-siglongjmp.m4 serial 5 (libsigsegv-2.6) +# sigaltstack-siglongjmp.m4 serial 6 (libsigsegv-2.6) dnl Copyright (C) 2002-2003, 2006, 2008 Bruno Haible <[EMAIL PROTECTED]> dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General @@ -51,7 +51,7 @@ int recurse (volatile int n) } int main () { - char mystack[SIGSTKSZ]; + char mystack[2 * SIGSTKSZ]; stack_t altstack; struct sigaction action; #ifdef __BEOS__ @@ -66,9 +66,10 @@ int main () rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */ setrlimit (RLIMIT_STACK, &rl); #endif - /* Install the alternate stack. */ - altstack.ss_sp = mystack; - altstack.ss_size = sizeof (mystack); + /* Install the alternate stack. Use midpoint to work around Irix + sigaltstack bug. */ + altstack.ss_sp = mystack + SIGSTKSZ; + altstack.ss_size = SIGSTKSZ; altstack.ss_flags = 0; /* no SS_DISABLE */ if (sigaltstack (&altstack, NULL) < 0) exit (1); Index: m4/sigaltstack.m4 =================================================================== RCS file: /sources/libsigsegv/libsigsegv/m4/sigaltstack.m4,v retrieving revision 1.12 diff -u -p -r1.12 sigaltstack.m4 --- m4/sigaltstack.m4 21 Sep 2008 13:41:28 -0000 1.12 +++ m4/sigaltstack.m4 23 Sep 2008 14:13:21 -0000 @@ -1,4 +1,4 @@ -# sigaltstack.m4 serial 9 (libsigsegv-2.7) +# sigaltstack.m4 serial 10 (libsigsegv-2.7) dnl Copyright (C) 2002-2006, 2008 Bruno Haible <[EMAIL PROTECTED]> dnl Copyright (C) 2008 Eric Blake <[EMAIL PROTECTED]> dnl This file is free software, distributed under the terms of the GNU @@ -74,7 +74,7 @@ int recurse (volatile int n) } int main () { - char mystack[SIGSTKSZ]; + char mystack[2 * SIGSTKSZ]; stack_t altstack; struct sigaction action; #if defined HAVE_SETRLIMIT && defined RLIMIT_STACK @@ -85,9 +85,10 @@ int main () rl.rlim_cur = rl.rlim_max = 0x100000; /* 1 MB */ setrlimit (RLIMIT_STACK, &rl); #endif - /* Install the alternate stack. */ - altstack.ss_sp = mystack; - altstack.ss_size = sizeof (mystack); + /* Install the alternate stack. Use midpoint to work around Irix + sigaltstack bug. */ + altstack.ss_sp = mystack + SIGSTKSZ; + altstack.ss_size = SIGSTKSZ; altstack.ss_flags = 0; /* no SS_DISABLE */ if (sigaltstack (&altstack, NULL) < 0) exit (1);