From owner-freebsd-current@freebsd.org Tue Aug 22 17:43:43 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70AA4DD7809 for ; Tue, 22 Aug 2017 17:43:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 54D4C6D9E5 for ; Tue, 22 Aug 2017 17:43:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 5406EDD7808; Tue, 22 Aug 2017 17:43:43 +0000 (UTC) Delivered-To: current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5396ADD7807 for ; Tue, 22 Aug 2017 17:43:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DFEBB6D9E3 for ; Tue, 22 Aug 2017 17:43:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v7MHhRAj079094 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Aug 2017 20:43:28 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v7MHhRAj079094 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v7MHhRMk079093; Tue, 22 Aug 2017 20:43:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 22 Aug 2017 20:43:27 +0300 From: Konstantin Belousov To: David Wolfskill , current@freebsd.org Subject: Re: SIGSEGV in /bin/sh after r322740 -> r322776 update Message-ID: <20170822174327.GK1700@kib.kiev.ua> References: <20170822114627.GC1130@albert.catwhisker.org> <20170822115923.GC1700@kib.kiev.ua> <20170822122836.GH1130@albert.catwhisker.org> <20170822123449.GD1700@kib.kiev.ua> <20170822124617.GN1130@albert.catwhisker.org> <20170822131958.GE1700@kib.kiev.ua> <20170822151738.GV1130@albert.catwhisker.org> <20170822153442.GG1700@kib.kiev.ua> <20170822160703.GW1130@albert.catwhisker.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170822160703.GW1130@albert.catwhisker.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 17:43:43 -0000 On Tue, Aug 22, 2017 at 09:07:03AM -0700, David Wolfskill wrote: > On Tue, Aug 22, 2017 at 06:34:42PM +0300, Konstantin Belousov wrote: > > ... > > > Bisection time? Or if there's another approach (or even a suggestion > > > for a revision to try first), I'm up for it. 9And yes, I'll just > > > be rebuilding the kernel for the rest of this exercise, I think. > > > That should speed things up significantly.) > > > > No need. It is clearly something with r322762 (more likely) or > > r322763 (less likely). > > Ah. > > > Give me some time, I either fix it today or revert the commits. > > Cool. I'm at work now, but if there's anything I can do (e.g., > testing), I will do what I can: I have serial console access to the > machine (for example). Try this. The patch helped ae@, it seems. I will commit it anyway in a hour, but more confirmations or nacks would be good. This patch has some debugging bits which add noise on console when a process traps. If this happens, please show me the lines. Thank you for the patience. diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index e5a69d715a7..d1de62d89a9 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -147,7 +147,7 @@ static int prot_fault_translation; SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RWTUN, &prot_fault_translation, 0, "Select signal to deliver on protection fault"); -static int uprintf_signal; +static int uprintf_signal = 1; SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN, &uprintf_signal, 0, "Print debugging information on trap signal to ctty"); @@ -559,7 +559,7 @@ trap(struct trapframe *frame) ksi.ksi_trapno = type; ksi.ksi_addr = (void *)addr; if (uprintf_signal) { - uprintf("pid %d comm %s: signal %d err %lx code %d type %d " + printf("pid %d comm %s: signal %d err %lx code %d type %d " "addr 0x%lx rsp 0x%lx rip 0x%lx " "<%02x %02x %02x %02x %02x %02x %02x %02x>\n", p->p_pid, p->p_comm, signo, frame->tf_err, ucode, type, @@ -572,6 +572,8 @@ trap(struct trapframe *frame) fubyte((void *)(frame->tf_rip + 5)), fubyte((void *)(frame->tf_rip + 6)), fubyte((void *)(frame->tf_rip + 7))); + printf("fsbase %#lx pcbfsbase %#lx flags %x\n", rdfsbase(), + td->td_pcb->pcb_fsbase, td->td_pcb->pcb_flags); } KASSERT((read_rflags() & PSL_I) != 0, ("interrupts disabled")); trapsignal(td, &ksi); diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index db82da4c8fe..f71378b36f8 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -172,6 +172,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) /* Ensure that td1's pcb is up to date. */ fpuexit(td1); + update_pcb_bases(td1->td_pcb); /* Point the pcb to the top of the stack */ pcb2 = get_pcb_td(td2); @@ -433,6 +434,7 @@ cpu_copy_thread(struct thread *td, struct thread *td0) * Those not loaded individually below get their default * values here. */ + update_pcb_bases(td0->td_pcb); bcopy(td0->td_pcb, pcb2, sizeof(*pcb2)); clear_pcb_flags(pcb2, PCB_FPUINITDONE | PCB_USERFPUINITDONE | PCB_KERNFPU);