Commit edfb1fd8 authored by Hans Wennborg's avatar Hans Wennborg Committed by Commit Bot

Fix base_unittests StackCopierSignalTest.CopyStack for new Clang

Newer Clang versions will perform "scalar replacement of aggregates"
optimization on the 'sentinels' array, breaking the test.

Leak the address of the array with debug::Alias to prevent that.

Bug: 1135294
Change-Id: I834b8406c0f91954207177294976250ac9c773f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462273Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816176}
parent bf1319df
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "base/debug/alias.h"
#include "base/profiler/sampling_profiler_thread_token.h" #include "base/profiler/sampling_profiler_thread_token.h"
#include "base/profiler/stack_buffer.h" #include "base/profiler/stack_buffer.h"
#include "base/profiler/stack_copier_signal.h" #include "base/profiler/stack_copier_signal.h"
...@@ -100,11 +101,11 @@ TEST(StackCopierSignalTest, MAYBE_CopyStack) { ...@@ -100,11 +101,11 @@ TEST(StackCopierSignalTest, MAYBE_CopyStack) {
ASSERT_TRUE(thread_delegate); ASSERT_TRUE(thread_delegate);
StackCopierSignal copier(std::move(thread_delegate)); StackCopierSignal copier(std::move(thread_delegate));
// Copy the sentinel values onto the stack. Volatile to defeat compiler // Copy the sentinel values onto the stack.
// optimizations. uint32_t sentinels[size(kStackSentinels)];
volatile uint32_t sentinels[size(kStackSentinels)];
for (size_t i = 0; i < size(kStackSentinels); ++i) for (size_t i = 0; i < size(kStackSentinels); ++i)
sentinels[i] = kStackSentinels[i]; sentinels[i] = kStackSentinels[i];
base::debug::Alias((void*)sentinels); // Defeat compiler optimizations.
bool result = copier.CopyStack(&stack_buffer, &stack_top, &timestamp, bool result = copier.CopyStack(&stack_buffer, &stack_top, &timestamp,
&context, &stack_copier_delegate); &context, &stack_copier_delegate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment