[PATCH] testsuite/98002 - fix gcc.dg/strncmp-2.c

Richard Biener rguenther@suse.de
Thu Nov 26 09:09:11 GMT 2020


This makes sure not to free() memory we have mprotected to PROT_NONE
by calling mprotect again with PROT_READ|PROT_WRITE.  This avoids
crashing the allocator when in debug mode.

Tested on x86_64-unknown-linux-gnu.

OK?

2020-11-16  Richard Biener  <rguenther@suse.de>

	PR testsuite/98002
	* gcc.dg/strncmp-2.c: Call mprotect again before free.
---
 gcc/testsuite/gcc.dg/strncmp-2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/strncmp-2.c b/gcc/testsuite/gcc.dg/strncmp-2.c
index 6818b304b36..0d84f932767 100644
--- a/gcc/testsuite/gcc.dg/strncmp-2.c
+++ b/gcc/testsuite/gcc.dg/strncmp-2.c
@@ -40,6 +40,7 @@ static void test_driver_strncmp (void (test_strncmp)(const char *, const char *,
     e = lib_memcmp(buf1,p2,sz);
     (*test_memcmp)(buf1,p2,e);
   }
+  mprotect (buf2+pgsz,pgsz,PROT_READ|PROT_WRITE);
   free(buf2);
 }
 
-- 
2.26.2


More information about the Gcc-patches mailing list