public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Use volatile pointers when attempting to trigger SIGSEGVs
Date: Tue, 30 Jun 2020 14:42:21 +0100	[thread overview]
Message-ID: <1593524541-3894-1-git-send-email-gbenson@redhat.com> (raw)

Hi all,

Clang fails to compile a number of files with the following warning:
indirection of non-volatile null pointer will be deleted, not trap
[-Wnull-dereference].  This patch qualifies the relevant pointers
with 'volatile'.

Checked on Fedora 31 x86_64, GCC and clang.  Ok to commit?

Cheers,
Gary

--
gdb/testsuite/ChangeLog:

	* gdb.base/bigcore.c (main): Use a volatile pointer when
	attempting to trigger a SIGSEGV.
	* gdb.base/gcore-relro-pie.c (break_here): Likewise.
	* gdb.base/gcore-tls-pie.c (break_here): Likewise.
	* gdb.base/savedregs.c (thrower): Likewise.
	* gdb.mi/mi-syn-frame.c (bar): Likewise.
---
 gdb/testsuite/ChangeLog                  | 9 +++++++++
 gdb/testsuite/gdb.base/bigcore.c         | 2 +-
 gdb/testsuite/gdb.base/gcore-relro-pie.c | 2 +-
 gdb/testsuite/gdb.base/gcore-tls-pie.c   | 2 +-
 gdb/testsuite/gdb.base/savedregs.c       | 2 +-
 gdb/testsuite/gdb.mi/mi-syn-frame.c      | 2 +-
 6 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.base/bigcore.c b/gdb/testsuite/gdb.base/bigcore.c
index 174e0f6..8be1b15 100644
--- a/gdb/testsuite/gdb.base/bigcore.c
+++ b/gdb/testsuite/gdb.base/bigcore.c
@@ -267,5 +267,5 @@ struct list
   /* Push everything out to disk.  */
 
   print_string ("Dump core ....\n");
-  *(char*)0 = 0;
+  *(volatile char*)0 = 0;
 }
diff --git a/gdb/testsuite/gdb.base/gcore-relro-pie.c b/gdb/testsuite/gdb.base/gcore-relro-pie.c
index 20cf12c..9ae7cb2 100644
--- a/gdb/testsuite/gdb.base/gcore-relro-pie.c
+++ b/gdb/testsuite/gdb.base/gcore-relro-pie.c
@@ -18,7 +18,7 @@
 void
 break_here (void)
 {
-  *(int *) 0 = 0;
+  *(volatile int *) 0 = 0;
 }
 
 void
diff --git a/gdb/testsuite/gdb.base/gcore-tls-pie.c b/gdb/testsuite/gdb.base/gcore-tls-pie.c
index 73aec40..18169fc 100644
--- a/gdb/testsuite/gdb.base/gcore-tls-pie.c
+++ b/gdb/testsuite/gdb.base/gcore-tls-pie.c
@@ -25,7 +25,7 @@
 void
 break_here (void)
 {
-  *(int *) 0 = 0;
+  *(volatile int *) 0 = 0;
 }
 
 void
diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c
index 71b076f..aec2a38 100644
--- a/gdb/testsuite/gdb.base/savedregs.c
+++ b/gdb/testsuite/gdb.base/savedregs.c
@@ -46,7 +46,7 @@
 thrower (void)
 {
   /* Trigger a SIGSEGV.  */
-  *(char *)0 = 0;
+  *(volatile char *)0 = 0;
 
   /* On MMU-less system, previous memory access to address zero doesn't
      trigger a SIGSEGV.  Trigger a SIGILL.  Each arch should define its
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.c b/gdb/testsuite/gdb.mi/mi-syn-frame.c
index c260112..b6ab6e8 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.c
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.c
@@ -27,7 +27,7 @@
 void 
 bar (void)
 {
-  *(char *)0 = 0;    /* try to cause a segfault */
+  *(volatile char *)0 = 0;    /* try to cause a segfault */
 
   /* On MMU-less system, previous memory access to address zero doesn't
      trigger a SIGSEGV.  Trigger a SIGILL.  Each arch should define its
-- 
1.8.3.1


             reply	other threads:[~2020-06-30 13:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 13:42 Gary Benson [this message]
2020-07-10 14:39 ` Pedro Alves
2020-07-13 13:50   ` Gary Benson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1593524541-3894-1-git-send-email-gbenson@redhat.com \
    --to=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).