Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode/usermode Use a alternative dedicated signa...



details:   https://anonhg.NetBSD.org/src/rev/a2199c69e4fd
branches:  trunk
changeset: 769166:a2199c69e4fd
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Thu Sep 01 18:20:20 2011 +0000

description:
Use a alternative dedicated signal stack for the sigsegv errors; the userland
stack like that of ld.elf_so can be too short to allow for such deep
stacktraces.

diffstat:

 sys/arch/usermode/usermode/trap.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (55 lines):

diff -r 6e12446770a8 -r a2199c69e4fd sys/arch/usermode/usermode/trap.c
--- a/sys/arch/usermode/usermode/trap.c Thu Sep 01 18:19:00 2011 +0000
+++ b/sys/arch/usermode/usermode/trap.c Thu Sep 01 18:20:20 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.15 2011/09/01 15:03:41 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.16 2011/09/01 18:20:20 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.15 2011/09/01 15:03:41 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.16 2011/09/01 18:20:20 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -56,6 +56,7 @@
 
 bool pmap_fault(pmap_t pmap, vaddr_t va, vm_prot_t *atype);
 
+static stack_t sigstk;
 static int debug_fh;
 
 void
@@ -69,12 +70,18 @@
        static struct sigaction sa;
 
        sigemptyset(&sa.sa_mask);
-       sa.sa_flags = SA_RESTART | SA_SIGINFO;
+       sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK;
        sa.sa_sigaction = mem_access_handler;
        if (thunk_sigaction(SIGSEGV, &sa, NULL) == -1)
                panic("couldn't register SIGSEGV handler : %d", errno);
        if (thunk_sigaction(SIGBUS, &sa, NULL) == -1)
                panic("couldn't register SIGBUS handler : %d", errno);
+       if ((sigstk.ss_sp = thunk_malloc(SIGSTKSZ)) == NULL)
+               panic("can't allocate signal stack space\n");
+       sigstk.ss_size  = SIGSTKSZ;
+       sigstk.ss_flags = 0;
+       if (thunk_sigaltstack(&sigstk, 0) < 0)
+               panic("can't set alternate stacksize : %d", errno);
 
        debug_fh = thunk_open("/usr/sources/debug", O_RDWR | O_TRUNC | O_CREAT, 0666);
 }
@@ -108,7 +115,7 @@
                onfault = pcb->pcb_onfault;
                vm = p->p_vmspace;
 
-#if 1
+#if 0
                va = (vaddr_t) info->si_addr;
                printf("trap lwp = %p pid = %d lid = %d, va = %p\n",
                    curlwp,



Home | Main Index | Thread Index | Old Index