1From ffb69e2384538a7d4b634bdc491d7da9b7220f57 Mon Sep 17 00:00:00 2001 2From: chenziyang <chenziyang4@huawei.com> 3Date: Tue, 11 Jul 2023 10:19:22 +0800 4Subject: [PATCH] avoid calling printf because OE glibc-2.34 used 5 -mno-outline-atomics buildflag, it will cause printf to be non-atomic 6 operations on ARMv8.1 platform. This will cause printf to stuck into dead 7 loop because ptrace sing-step execution cause race condition during printf 8 instructions. 9 10--- 11 tests/mapper.c | 11 ++++++++++- 12 1 file changed, 10 insertions(+), 1 deletion(-) 13 14diff --git a/tests/mapper.c b/tests/mapper.c 15index b47ae78..fcfb080 100644 16--- a/tests/mapper.c 17+++ b/tests/mapper.c 18@@ -43,6 +43,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 19 # define MAP_NORESERVE 0 20 #endif 21 22+void __attribute__((noinline)) push_some_stacks(int n) 23+{ 24+ if (n >= 1) 25+ { 26+ push_some_stacks(n - 1); 27+ push_some_stacks(n - 1); 28+ } 29+} 30+ 31 int 32 main (void) 33 { 34@@ -71,7 +80,7 @@ main (void) 35 36 printf ("Turning on single-stepping...\n"); 37 kill (getpid (), SIGUSR1); /* tell test-ptrace to start single-stepping */ 38- printf ("Va bene?\n"); 39+ push_some_stacks (4); 40 kill (getpid (), SIGUSR2); /* tell test-ptrace to stop single-stepping */ 41 printf ("Turned single-stepping off...\n"); 42 return 0; 43-- 442.33.0 45 46 47