bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module 'sigsegv'


From: Bruno Haible
Subject: Re: new module 'sigsegv'
Date: Mon, 07 Jun 2021 02:49:35 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; )

Hi Dmitry,

> I've tried to rebuild the latest GNU grep with the latest gnulib
> and got a few build issues:
> ...
> The following gnulib patch makes the compiler happy again:
> 
> diff --git a/lib/sigsegv.c b/lib/sigsegv.c
> index 312f132b8..b0b406685 100644
> --- a/lib/sigsegv.c
> +++ b/lib/sigsegv.c
> @@ -1056,7 +1056,7 @@ sigsegv_handler (SIGSEGV_FAULT_HANDLER_ARGLIST)
>            /* Handler declined responsibility for real.  */
>  
>            /* Remove ourselves and dump core.  */
> -          SIGSEGV_FOR_ALL_SIGNALS (sig, signal (sig, SIG_DFL);)
> +          SIGSEGV_FOR_ALL_SIGNALS (signo, signal (signo, SIG_DFL);)
>          }
>  
>  # if HAVE_STACK_OVERFLOW_RECOVERY

Thanks for the report. This patch is good, but needs to be applied also to
the other sigsegv_handler, and also to libsigsegv (to be kept in sync when
possible). I'm doing that now.

>  
> -volatile int *
> +static volatile int *
>  recurse_1 (int n, volatile int *p)
>  {
>    if (n < INT_MAX)
> @@ -80,7 +80,7 @@ recurse_1 (int n, volatile int *p)
>    return p;
>  }
>  
> -int
> +static int
>  recurse (volatile int n)
>  {
>    return *recurse_1 (n, &n);

This part should better not be applied. It may enable compiler optimizations
(now or in the future) that, in the end, turn an endless recursion into an
endless loop.

> @@ -183,6 +183,9 @@ main ()
>        *(volatile int *) (page + 0x678) = 42;
>        break;
>      case 3:
> +#if 6 < __GNUC__
> +# pragma GCC diagnostic ignored "-Wnull-dereference"
> +#endif
>        *(volatile int *) 0 = 42;
>        break;
>      case 4:

We shouldn't spend time eliminating warnings from test code.

The goal is to have a good coverage of the lib/* code with unit tests.
That means, we need to
  - make it easy to write unit tests,
  - not make it time-consuming to maintain them.

Eliminating warnings from lib/* code is useful, to avoid bugs in the
programs. But eliminating warnings from tests/* code goes against the
goal of increasing test coverage.

I think the right fix would be that gnulib-tool's --import/--update
option, when creating a tests directory, adds a $(CFLAG_ALLOW_WARNING)
to tests/Makefile.am, where CFLAG_ALLOW_WARNING is defined as
  -Wno-error  when the compiler is GCC or clang,
  empty       otherwise
Will that work in GNU grep?

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]