Index: linux-user/signal.c =================================================================== RCS file: /cvsroot/qemu/qemu/linux-user/signal.c,v retrieving revision 1.27 diff -u -r1.27 signal.c --- linux-user/signal.c 30 Jan 2005 22:59:18 -0000 1.27 +++ linux-user/signal.c 22 Mar 2005 12:42:30 -0000 @@ -1019,6 +1026,14 @@ return err; } +void* hack_stack; + +void hack_handler(int signum) +{ + fprintf(stderr,"QEMU: stack overflow, aborting\n"); + exit(-SIGSEGV); +} + static inline void * get_sigframe(struct emulated_sigaction *ka, CPUState *regs, int framesize) { @@ -1031,6 +1046,19 @@ if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) sp = current->sas_ss_sp + current->sas_ss_size; #endif + + /* EVIL HACK TIME! + This is supposed to prevent endless segfault loops in case of stack + overflows that can occur as a result of the dummy sigaltstack() + syscall. */ + struct sigaction oldact; + struct sigaction act; + memset(&act,0,sizeof(struct sigaction)); + act.sa_handler=hack_handler; + sigaction(SIGSEGV,&act,&oldact); + hack_stack = *((void**)((sp-framesize)&~7)); + sigaction(SIGSEGV,&oldact,&act); + /* * ATPCS B01 mandates 8-byte alignment */ Index: linux-user/syscall.c =================================================================== RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.58 diff -u -r1.58 syscall.c --- linux-user/syscall.c 1 Mar 2005 22:32:06 -0000 1.58 +++ linux-user/syscall.c 22 Mar 2005 12:42:30 -0000 @@ -2725,7 +2734,8 @@ case TARGET_NR_capset: goto unimplemented; case TARGET_NR_sigaltstack: - goto unimplemented; + ret = 0; /* good enough for most purposes */ + break; case TARGET_NR_sendfile: goto unimplemented; #ifdef TARGET_NR_getpmsg