https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/151201

Backport fcdcc4ea7ac960c79246b3bd428f14ea350e63e2

Requested by: @mgorny

>From 402baf292c61c3a8f2916ac6abc4b3b93597c640 Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <fdu...@google.com>
Date: Tue, 22 Jul 2025 03:31:35 +0200
Subject: [PATCH] [scudo] Make Ptr volatile so that the malloc and free calls
 are not optimized out (#149944)

This fixes the test failure seen in the discussion about
https://github.com/llvm/llvm-project/pull/148066.

(cherry picked from commit fcdcc4ea7ac960c79246b3bd428f14ea350e63e2)
---
 compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp 
b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
index 05065444a70c5..612317b3c3293 100644
--- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -183,7 +183,8 @@ TEST_F(ScudoWrappersCDeathTest, Malloc) {
   // process doing free(P) is not a double free.
   EXPECT_DEATH(
       {
-        void *Ptr = malloc(Size);
+        // Note: volatile here prevents the calls from being optimized out.
+        void *volatile Ptr = malloc(Size);
         free(Ptr);
         free(Ptr);
       },

_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to