]> 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, 1 May 2019 01:17:39 +0000 (18:17 -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 8702e7e1c57e7b4e61b3ffad2f2a45bc38605f33..4e7fee9fc113384105ed42e64e99eeaf87697dd4 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 15e25f558e77f9a5924a7a56fd97137709df51d2..654bc2e408d9facfc820edac3e2080235af50839 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 f9552226efc5267e68ae019524b08724a6c25d6c..5b62efd99848d8b79f2e621e316f598946cb3c87 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 ac44cb8a6c4c5f872a12c21713e9fa158b962089..7399b0bb235fae78ab103fd9bb464875b09d33db 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 a2e27c1e91ed3dd35fd5062234a31280a90e28a1..d1c3f81772f5bf0544ea2378b3805ebd13084e29 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;