public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/grte] Defeat a malloc optimization by declaring things volatile.
@ 2021-08-27 23:25 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-08-27 23:25 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=58f9551f5bac093dac2dcf3c66e32a4934ff8bd6

commit 58f9551f5bac093dac2dcf3c66e32a4934ff8bd6
Author: Stan Shebs <stanshebs@google.com>
Date:   Wed May 9 11:28:09 2018 -0700

    Defeat a malloc optimization by declaring things volatile.

Diff:
---
 malloc/tst-malloc-backtrace.c | 4 ++--
 malloc/tst-malloc-too-large.c | 2 +-
 malloc/tst-malloc.c           | 2 +-
 malloc/tst-mcheck.c           | 2 +-
 malloc/tst-valloc.c           | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/malloc/tst-malloc-backtrace.c b/malloc/tst-malloc-backtrace.c
index 171cfcefb8..b1708b3529 100644
--- a/malloc/tst-malloc-backtrace.c
+++ b/malloc/tst-malloc-backtrace.c
@@ -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();
diff --git a/malloc/tst-malloc-too-large.c b/malloc/tst-malloc-too-large.c
index 10fb136528..bdd2a9eebc 100644
--- a/malloc/tst-malloc-too-large.c
+++ b/malloc/tst-malloc-too-large.c
@@ -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);
diff --git a/malloc/tst-malloc.c b/malloc/tst-malloc.c
index aa1aa2aa41..bd10351246 100644
--- a/malloc/tst-malloc.c
+++ b/malloc/tst-malloc.c
@@ -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;
diff --git a/malloc/tst-mcheck.c b/malloc/tst-mcheck.c
index 18b0d59bd9..d4c427bc90 100644
--- a/malloc/tst-mcheck.c
+++ b/malloc/tst-mcheck.c
@@ -33,7 +33,7 @@ merror (const char *msg)
 static int
 do_test (void)
 {
-  void *p, *q;
+  void *volatile p, *volatile q;
 
   errno = 0;
 
diff --git a/malloc/tst-valloc.c b/malloc/tst-valloc.c
index ba57d9559a..b28163afe0 100644
--- a/malloc/tst-valloc.c
+++ b/malloc/tst-valloc.c
@@ -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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-27 23:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 23:25 [glibc/maskray/grte] Defeat a malloc optimization by declaring things volatile Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).