]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Defeat a malloc optimization by declaring things volatile.
authorStan Shebs <stanshebs@google.com>
Wed, 9 May 2018 18:28:09 +0000 (11:28 -0700)
committerStan Shebs <stanshebs@google.com>
Wed, 9 May 2018 18:28:09 +0000 (11:28 -0700)
malloc/tst-malloc-backtrace.c
malloc/tst-malloc-too-large.c
malloc/tst-malloc.c
malloc/tst-mcheck.c
malloc/tst-valloc.c

index 171cfcefb8fbd2b055b202cc9148a20634d12bcd..b1708b3529798272f6d57193285ccc6f6e6029dd 100644 (file)
@@ -35,8 +35,8 @@ call_free (void *ptr)
 int
 do_test (void)
 {
-  void *ptr1 = malloc (SIZE);
-  void *ptr2 = malloc (SIZE);
+  void *volatile ptr1 = malloc (SIZE);
+  void *volatile ptr2 = malloc (SIZE);
 
   /* Avoid unwanted output to TTY after an expected memory corruption.  */
   ignore_stderr();
index 10fb1365280d42b9764cd6690dcc4dae3b0633ba..bdd2a9eebcf187f0232050edc5a83f6bf576f799 100644 (file)
@@ -69,7 +69,7 @@ test_setup (void)
 static void
 test_large_allocations (size_t size)
 {
-  void * ptr_to_realloc;
+  void *volatile ptr_to_realloc;
 
   test_setup ();
   TEST_VERIFY (malloc (size) == NULL);
index aa1aa2aa41a39c7a3be00d0f525c839499e9d540..bd10351246c1c5c42e2002bd1e31797d11b65a5f 100644 (file)
@@ -33,7 +33,7 @@ merror (const char *msg)
 static int
 do_test (void)
 {
-  void *p, *q;
+  void *volatile p, *volatile q;
   int save;
 
   errno = 0;
index 18b0d59bd9e8b313ad5524c667d5ea6b1d7bd8f0..d4c427bc90cb2bd33387b9bd0bc977438da98a93 100644 (file)
@@ -33,7 +33,7 @@ merror (const char *msg)
 static int
 do_test (void)
 {
-  void *p, *q;
+  void *volatile p, *volatile q;
 
   errno = 0;
 
index ba57d9559aa46867a5293ebd388aeda4f1b0ef4a..b28163afe0612629d4090f15be868ccff8eeeb27 100644 (file)
@@ -34,7 +34,7 @@ merror (const char *msg)
 static int
 do_test (void)
 {
-  void *p;
+  void *volatile p;
   unsigned long pagesize = getpagesize ();
   unsigned long ptrval;
   int save;