From 7a40859e1e4b9e86eceee353d5de9bd57e20211e Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 22 Aug 2022 14:25:29 +0200 Subject: [PATCH] test: fix DebugSymbolsTest.ReqWrapList on PPC64LE Currently, DebugSymbolsTest.ReqWrapList fails on PPC64LE when Node has been configured with Link Time Optimization (LTO) and using RHEL 8.5 and gcc: ```console $ . /opt/rh/gcc-toolset-11/enable $ export CC='ccache gcc' $ export CXX='ccache g++' $ ./configure --enable-lto $ make -j8 cctest ... 21:52:27 [ RUN ] DebugSymbolsTest.ReqWrapList 21:52:27 ../test/cctest/test_node_postmortem_metadata.cc:203: Failure 21:52:27 Expected equality of these values: 21:52:27 expected 21:52:27 Which is: 140736537072320 21:52:27 calculated 21:52:27 Which is: 1099680328560 21:52:27 [ FAILED ] DebugSymbolsTest.ReqWrapList (43 ms) ``` After looking into this is seems that the compiler is tampering with one or more of the `queue`, `head`, `tail`, and `last` variables when compiling with LTO enabled. This commit suggests adding volatile to these variables to prevent the compiler from tampering with them. --- test/cctest/test_node_postmortem_metadata.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/cctest/test_node_postmortem_metadata.cc b/test/cctest/test_node_postmortem_metadata.cc index 4cee7db4c8ee5b3..7d5d73171d3444f 100644 --- a/test/cctest/test_node_postmortem_metadata.cc +++ b/test/cctest/test_node_postmortem_metadata.cc @@ -172,11 +172,13 @@ TEST_F(DebugSymbolsTest, ReqWrapList) { const Argv argv; Env env{handle_scope, argv}; - auto queue = reinterpret_cast((*env)->req_wrap_queue()); - auto head = + volatile uintptr_t queue = + reinterpret_cast((*env)->req_wrap_queue()); + volatile uintptr_t head = queue + nodedbg_offset_Environment_ReqWrapQueue__head___ListNode_ReqWrapQueue; - auto tail = head + nodedbg_offset_ListNode_ReqWrap__prev___uintptr_t; + volatile uintptr_t tail = head + + nodedbg_offset_ListNode_ReqWrap__prev___uintptr_t; tail = *reinterpret_cast(tail); auto obj_template = v8::FunctionTemplate::New(isolate_); @@ -194,11 +196,12 @@ TEST_F(DebugSymbolsTest, ReqWrapList) { // ARM64 CI machinies. for (auto it : *(*env)->req_wrap_queue()) (void) ⁢ - auto last = tail + nodedbg_offset_ListNode_ReqWrap__next___uintptr_t; + volatile uintptr_t last = tail + + nodedbg_offset_ListNode_ReqWrap__next___uintptr_t; last = *reinterpret_cast(last); - auto expected = reinterpret_cast(&obj); - auto calculated = + volatile uintptr_t expected = reinterpret_cast(&obj); + volatile uintptr_t calculated = last - nodedbg_offset_ReqWrap__req_wrap_queue___ListNode_ReqWrapQueue; EXPECT_EQ(expected, calculated);