comparison lib/c-stack.c @ 10358:37fd490ee38d

c-stack: test that stack overflow can be caught * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Also check that platform allows handling stack overflow; at least OS/2 EMX has sigaltstack, but crashes before transferring control to handler on stack overflow. * lib/c-stack.c [HAVE_SIGALTSTACK]: Adjust conditions to also check for HAVE_STACK_OVERFLOW_HANDLING. Reported by Elbert Pol. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Mon, 25 Aug 2008 06:26:56 -0600
parents 9c24129c10e2
children 9867f4fee019
comparison
equal deleted inserted replaced
10357:ae4cf624bf35 10358:37fd490ee38d
115 _exit (exit_failure); 115 _exit (exit_failure);
116 raise (signo); 116 raise (signo);
117 abort (); 117 abort ();
118 } 118 }
119 119
120 #if (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK) || HAVE_LIBSIGSEGV 120 #if (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK \
121 && HAVE_STACK_OVERFLOW_HANDLING) || HAVE_LIBSIGSEGV
121 122
122 /* Storage for the alternate signal stack. */ 123 /* Storage for the alternate signal stack. */
123 static union 124 static union
124 { 125 {
125 char buffer[SIGSTKSZ]; 126 char buffer[SIGSTKSZ];
208 segv as stack overflow. */ 209 segv as stack overflow. */
209 segv_handler_missing = sigsegv_install_handler (segv_handler); 210 segv_handler_missing = sigsegv_install_handler (segv_handler);
210 return 0; 211 return 0;
211 } 212 }
212 213
213 #elif HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK 214 #elif HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_OVERFLOW_HANDLING
214 215
215 /* Direction of the C runtime stack. This function is 216 /* Direction of the C runtime stack. This function is
216 async-signal-safe. */ 217 async-signal-safe. */
217 218
218 # if STACK_DIRECTION 219 # if STACK_DIRECTION
314 # endif 315 # endif
315 316
316 return sigaction (SIGSEGV, &act, NULL); 317 return sigaction (SIGSEGV, &act, NULL);
317 } 318 }
318 319
319 #else /* ! ((HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK) || HAVE_LIBSIGSEGV) */ 320 #else /* ! ((HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK
321 && HAVE_STACK_OVERFLOW_HANDLING) || HAVE_LIBSIGSEGV) */
320 322
321 int 323 int
322 c_stack_action (void (*action) (int) __attribute__ ((unused))) 324 c_stack_action (void (*action) (int) __attribute__ ((unused)))
323 { 325 {
324 errno = ENOTSUP; 326 errno = ENOTSUP;