Use volatile pointers when attempting to trigger SIGSEGVs

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 commit qualifies the relevant pointers
with 'volatile'.

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.
This commit is contained in:
Gary Benson
2020-07-13 14:47:44 +01:00
parent 3f00c730ac
commit 2a122642b4
6 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,12 @@
2020-07-13 Gary Benson <gbenson@redhat.com>
* 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.
2020-07-13 Gary Benson <gbenson@redhat.com>
* gdb.base/vla-datatypes.c (vla_factory): Factor out sections

View File

@ -267,5 +267,5 @@ main ()
/* Push everything out to disk. */
print_string ("Dump core ....\n");
*(char*)0 = 0;
*(volatile char*)0 = 0;
}

View File

@ -18,7 +18,7 @@
void
break_here (void)
{
*(int *) 0 = 0;
*(volatile int *) 0 = 0;
}
void

View File

@ -25,7 +25,7 @@ __thread char i;
void
break_here (void)
{
*(int *) 0 = 0;
*(volatile int *) 0 = 0;
}
void

View File

@ -46,7 +46,7 @@ static void
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

View File

@ -27,7 +27,7 @@ foo (void)
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