This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[testsuite, PR83612] Fix 'memory cannot be printed' in gcc.dg/ubsan/object-size-9.c


Hi,

I ran into the following failure:
...
FAIL: gcc.dg/ubsan/object-size-9.c -O2 output pattern test, is gcc.dg/ubsan/object-size-9.c:11:13: runtime error: load of address 0x000000600ff2 with insufficient space for an object of type 'char'
0x000000600ff2: note: pointer points here
<memory cannot be printed>
...
The failure is because the test-case expects the sanitizer to access the memory and print its contents, but the memory happens not to be not accessible.

I've applied the same fix as was applied in c-c++-common/ubsan/object-size-9.c for PR sanitizer/64078: add an alignment attribute to the variable to ensure that the memory after the variable is accessible.

Tested on x86_64.

Committed as obvious.

Thanks,
- Tom
Fix 'memory cannot be printed' in gcc.dg/ubsan/object-size-9.c

2017-12-30  Tom de Vries  <tom@codesourcery.com>

	PR testsuite/83612
	* gcc.dg/ubsan/object-size-9 (t): Add alignment attribute.

---
 gcc/testsuite/gcc.dg/ubsan/object-size-9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/ubsan/object-size-9.c b/gcc/testsuite/gcc.dg/ubsan/object-size-9.c
index e0a2980..41c4a94 100644
--- a/gcc/testsuite/gcc.dg/ubsan/object-size-9.c
+++ b/gcc/testsuite/gcc.dg/ubsan/object-size-9.c
@@ -3,7 +3,7 @@
 /* { dg-options "-fsanitize=undefined" } */
 
 struct T { int c; char d[]; };
-struct T t = { 1, "a" };
+struct T t __attribute__ ((aligned(4096))) = { 1, "a" };
 
 int
 baz (int i)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]