From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id B54281F5AE for ; Mon, 7 Jun 2021 01:24:32 +0000 (UTC) Received: from localhost ([::1]:47158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lq40F-0003iU-K2 for normalperson@yhbt.net; Sun, 06 Jun 2021 21:24:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lq3yu-00009T-40 for bug-gnulib@gnu.org; Sun, 06 Jun 2021 21:23:08 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:57126) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lq3ys-0002Lp-1I for bug-gnulib@gnu.org; Sun, 06 Jun 2021 21:23:07 -0400 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id DF04672C8B0; Mon, 7 Jun 2021 02:27:56 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id CFAA47CC8BB; Mon, 7 Jun 2021 02:27:56 +0300 (MSK) Date: Mon, 7 Jun 2021 02:27:56 +0300 From: "Dmitry V. Levin" To: Bruno Haible Subject: Re: new module 'sigsegv' Message-ID: <20210606232756.GA17371@altlinux.org> References: <15897619.AQZsorJ5YP@omega> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15897619.AQZsorJ5YP@omega> Received-SPF: pass client-ip=194.107.17.57; envelope-from=ldv@altlinux.org; helo=vmicros1.altlinux.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" On Sun, May 16, 2021 at 07:01:45PM +0200, Bruno Haible wrote: [...] > To fix this problem, I'm adding a module 'sigsegv'. I've tried to rebuild the latest GNU grep with the latest gnulib and got a few build issues: sigsegv.c: In function 'sigsegv_handler': sigsegv.c:1059:36: error: declaration of 'sig' shadows a parameter [-Werror=shadow] 1059 | SIGSEGV_FOR_ALL_SIGNALS (sig, signal (sig, SIG_DFL);) | ^~~ sigsegv.c:738:11: note: in definition of macro 'SIGSEGV_FOR_ALL_SIGNALS' 738 | { int var; var = SIGSEGV; { body } } | ^~~ sigsegv.c:64:45: note: shadowed declaration is here 64 | # define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, siginfo_t *sip, void *ucp | ~~~~^~~ sigsegv.c:915:18: note: in expansion of macro 'SIGSEGV_FAULT_HANDLER_ARGLIST' 915 | sigsegv_handler (SIGSEGV_FAULT_HANDLER_ARGLIST) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test-sigsegv-catch-segv1.c:42:1: error: no previous prototype for 'handler' [-Werror=missing-prototypes] 42 | handler (void *fault_address, int serious) | ^~~~~~~ test-sigsegv-catch-segv1.c:56:1: error: no previous prototype for 'crasher' [-Werror=missing-prototypes] 56 | crasher (uintptr_t p) | ^~~~~~~ test-sigsegv-catch-segv2.c:61:1: error: no previous prototype for 'handler' [-Werror=missing-prototypes] 61 | handler (void *fault_address, int serious) | ^~~~~~~ test-sigsegv-catch-segv2.c:76:1: error: no previous prototype for 'crasher' [-Werror=missing-prototypes] 76 | crasher (uintptr_t p) | ^~~~~~~ test-sigsegv-catch-stackoverflow1.c:62:1: error: no previous prototype for 'stackoverflow_handler' [-Werror=missing-prototypes] 62 | stackoverflow_handler (int emergency, stackoverflow_context_t scp) | ^~~~~~~~~~~~~~~~~~~~~ test-sigsegv-catch-stackoverflow1.c:76:1: error: no previous prototype for 'recurse_1' [-Werror=missing-prototypes] 76 | recurse_1 (int n, volatile int *p) | ^~~~~~~~~ test-sigsegv-catch-stackoverflow1.c:84:1: error: no previous prototype for 'recurse' [-Werror=missing-prototypes] 84 | recurse (volatile int n) | ^~~~~~~ test-sigsegv-catch-stackoverflow2.c:62:1: error: no previous prototype for 'stackoverflow_handler' [-Werror=missing-prototypes] 62 | stackoverflow_handler (int emergency, stackoverflow_context_t scp) | ^~~~~~~~~~~~~~~~~~~~~ test-sigsegv-catch-stackoverflow2.c:78:1: error: no previous prototype for 'sigsegv_handler' [-Werror=missing-prototypes] 78 | sigsegv_handler (void *address, int emergency) | ^~~~~~~~~~~~~~~ test-sigsegv-catch-stackoverflow2.c:98:1: error: no previous prototype for 'recurse_1' [-Werror=missing-prototypes] 98 | recurse_1 (int n, volatile int *p) | ^~~~~~~~~ test-sigsegv-catch-stackoverflow2.c:106:1: error: no previous prototype for 'recurse' [-Werror=missing-prototypes] 106 | recurse (volatile int n) | ^~~~~~~ test-sigsegv-catch-stackoverflow2.c: In function 'main': test-sigsegv-catch-stackoverflow2.c:186:27: error: null pointer dereference [-Werror=null-dereference] 186 | *(volatile int *) 0 = 42; | ~~~~~~~~~~~~~~~~~~~~^~~~ 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 diff --git a/tests/test-sigsegv-catch-segv1.c b/tests/test-sigsegv-catch-segv1.c index 62eef69c8..741a37878 100644 --- a/tests/test-sigsegv-catch-segv1.c +++ b/tests/test-sigsegv-catch-segv1.c @@ -38,7 +38,7 @@ uintptr_t page; volatile int handler_called = 0; -int +static int handler (void *fault_address, int serious) { handler_called++; @@ -52,7 +52,7 @@ handler (void *fault_address, int serious) return 0; } -void +static void crasher (uintptr_t p) { *(volatile int *) (p + 0x678) = 42; diff --git a/tests/test-sigsegv-catch-segv2.c b/tests/test-sigsegv-catch-segv2.c index dd28517f9..f28cb0a8e 100644 --- a/tests/test-sigsegv-catch-segv2.c +++ b/tests/test-sigsegv-catch-segv2.c @@ -57,7 +57,7 @@ handler_continuation (void *arg1, void *arg2, void *arg3) longjmp (mainloop, pass); } -int +static int handler (void *fault_address, int serious) { handler_called++; @@ -72,7 +72,7 @@ handler (void *fault_address, int serious) return sigsegv_leave_handler (handler_continuation, NULL, NULL, NULL); } -void +static void crasher (uintptr_t p) { *(volatile int *) (p + 0x678 + 8 * pass) = 42; diff --git a/tests/test-sigsegv-catch-stackoverflow1.c b/tests/test-sigsegv-catch-stackoverflow1.c index c828ed282..bfa04ae8b 100644 --- a/tests/test-sigsegv-catch-stackoverflow1.c +++ b/tests/test-sigsegv-catch-stackoverflow1.c @@ -58,7 +58,7 @@ stackoverflow_handler_continuation (void *arg1, void *arg2, void *arg3) longjmp (mainloop, arg); } -void +static void stackoverflow_handler (int emergency, stackoverflow_context_t scp) { char dummy; @@ -72,7 +72,7 @@ stackoverflow_handler (int emergency, stackoverflow_context_t scp) (void *) (long) (emergency ? -1 : pass), NULL, NULL); } -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); diff --git a/tests/test-sigsegv-catch-stackoverflow2.c b/tests/test-sigsegv-catch-stackoverflow2.c index b94d1310b..f7fd191a6 100644 --- a/tests/test-sigsegv-catch-stackoverflow2.c +++ b/tests/test-sigsegv-catch-stackoverflow2.c @@ -58,7 +58,7 @@ stackoverflow_handler_continuation (void *arg1, void *arg2, void *arg3) longjmp (mainloop, arg); } -void +static void stackoverflow_handler (int emergency, stackoverflow_context_t scp) { pass++; @@ -74,7 +74,7 @@ stackoverflow_handler (int emergency, stackoverflow_context_t scp) (void *) (long) (emergency ? -1 : pass), NULL, NULL); } -int +static int sigsegv_handler (void *address, int emergency) { /* This test is necessary to distinguish stack overflow and SIGSEGV. */ @@ -94,7 +94,7 @@ sigsegv_handler (void *address, int emergency) (void *) (long) pass, NULL, NULL); } -volatile int * +static volatile int * recurse_1 (int n, volatile int *p) { if (n < INT_MAX) @@ -102,7 +102,7 @@ recurse_1 (int n, volatile int *p) return p; } -int +static int recurse (volatile int n) { return *recurse_1 (n, &n); @@ -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: -- ldv