Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Mar 2019 20:21:00 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bruce Evans <bde@FreeBSD.org>
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>
In-Reply-To: <201903291557.x2TFv9AW097226@repo.freebsd.org>
References:  <201903291557.x2TFv9AW097226@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/cdefs.h>
>  __FBSDID("$FreeBSD$");
>  
> +#include <signal.h>
>  #include <stdio.h>
>  #include <sys/types.h>
> -#include <sys/signal.h>
>  #include <sys/file.h>
>  #include <sys/ioctl.h>
>  #include <sys/mman.h>
> @@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190329182100.GZ1923>