From owner-svn-src-all@freebsd.org Fri Mar 29 18:21:09 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C2D4154DAA2; Fri, 29 Mar 2019 18:21:09 +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 5DC067257B; Fri, 29 Mar 2019 18:21:08 +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 x2TIL0nQ052388 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 29 Mar 2019 20:21:03 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x2TIL0nQ052388 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x2TIL039052386; Fri, 29 Mar 2019 20:21:00 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 29 Mar 2019 20:21:00 +0200 From: Konstantin Belousov To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r345696 - head/lib/libvgl Message-ID: <20190329182100.GZ1923@kib.kiev.ua> References: <201903291557.x2TFv9AW097226@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201903291557.x2TFv9AW097226@repo.freebsd.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Mar 2019 18:21:09 -0000 On Fri, Mar 29, 2019 at 03:57:09PM +0000, Bruce Evans wrote: > Author: bde > Date: Fri Mar 29 15:57:08 2019 > New Revision: 345696 > URL: https://svnweb.freebsd.org/changeset/base/345696 > > Log: > Fix endless loops for handling SIGBUS and SIGSEGV. > > r80270 has the usual wrong fix for unsafe signal handling -- just set > a flag and return to let an event loop check the flag and do safe > handling. This never works for signals like SIGBUS and SIGSEGV that > repeat and works poorly for others unless the application has an event > loop designed to support this. > > For these signals, clean up unsafely as before, except for arranging that > nested signals are fatal and forcing a nested signal if the cleanup doesn't > cause one. > > Modified: > head/lib/libvgl/main.c > > Modified: head/lib/libvgl/main.c > ============================================================================== > --- head/lib/libvgl/main.c Fri Mar 29 15:20:48 2019 (r345695) > +++ head/lib/libvgl/main.c Fri Mar 29 15:57:08 2019 (r345696) > @@ -31,9 +31,9 @@ > #include > __FBSDID("$FreeBSD$"); > > +#include > #include > #include > -#include > #include > #include > #include > @@ -107,14 +107,22 @@ struct vt_mode smode; > } > > static void > -VGLAbort(int arg __unused) > +VGLAbort(int arg) > { > + sigset_t mask; > + > VGLAbortPending = 1; > signal(SIGINT, SIG_IGN); > signal(SIGTERM, SIG_IGN); > - signal(SIGSEGV, SIG_IGN); > - signal(SIGBUS, SIG_IGN); > signal(SIGUSR2, SIG_IGN); > + if (arg == SIGBUS || arg == SIGSEGV) { > + signal(arg, SIG_DFL); > + sigemptyset(&mask); > + sigaddset(&mask, arg); > + sigprocmask(SIG_UNBLOCK, &mask, NULL); > + VGLEnd(); > + kill(getpid(), arg); This of course misses the siginfo information from the real fault. Why SIGBUS/SIGSEGV are caught at all ? > + } > } > > static void