Commit d78fee6d authored by Wez's avatar Wez Committed by Commit Bot

[base] Remove markers around on-stack copy of fatal log messages.

LOG(FATAL) message content is now provided in Crashpad dumps via an
annotation, so there is no longer value in providing markers to allow
the stack to be scanned for the message.

Removing this also avoids the need to update the test not to cause
failures in ASAN builds.

Bug: 802393, 1119821
Change-Id: I6a64778f4da527597e9bb0874fe5764fbf87716a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404926
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: default avatarJoshua Peraza <jperaza@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806252}
parent 67677e8e
...@@ -832,17 +832,8 @@ LogMessage::~LogMessage() { ...@@ -832,17 +832,8 @@ LogMessage::~LogMessage() {
if (tracker) if (tracker)
tracker->RecordLogMessage(str_newline); tracker->RecordLogMessage(str_newline);
// Ensure the first characters of the string are on the stack so they char str_stack[1024];
// are contained in minidumps for diagnostic purposes. We place start base::strlcpy(str_stack, str_newline.data(), base::size(str_stack));
// and end marker values at either end, so we can scan captured stacks
// for the data easily.
struct {
uint32_t start_marker = 0xbedead01;
char data[1024];
uint32_t end_marker = 0x5050dead;
} str_stack;
base::strlcpy(str_stack.data, str_newline.data(),
base::size(str_stack.data));
base::debug::Alias(&str_stack); base::debug::Alias(&str_stack);
if (!GetLogAssertHandlerStack().empty()) { if (!GetLogAssertHandlerStack().empty()) {
......
...@@ -904,57 +904,6 @@ TEST_F(LoggingTest, LogCrosSyslogFormat) { ...@@ -904,57 +904,6 @@ TEST_F(LoggingTest, LogCrosSyslogFormat) {
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && \
!BUILDFLAG(IS_HWASAN)
// Since we scan potentially uninitialized portions of the stack, we can't run
// this test under any sanitizer that checks for uninitialized reads.
TEST_F(LoggingTest, LogMessageMarkersOnStack) {
const uint32_t kLogStartMarker = 0xbedead01;
const uint32_t kLogEndMarker = 0x5050dead;
const char kTestMessage[] = "Oh noes! I have crashed! 💩";
uint32_t stack_start = 0;
// Install a LogAssertHandler which will scan between |stack_start| and its
// local-scope stack for the start & end markers, and verify the message.
ScopedLogAssertHandler assert_handler(base::BindRepeating(
[](uint32_t* stack_start_ptr, const char* file, int line,
const base::StringPiece message, const base::StringPiece stack_trace) {
uint32_t stack_end;
uint32_t* stack_end_ptr = &stack_end;
// Scan the stack for the expected markers.
uint32_t* start_marker = nullptr;
uint32_t* end_marker = nullptr;
for (uint32_t* ptr = stack_end_ptr; ptr <= stack_start_ptr; ++ptr) {
if (*ptr == kLogStartMarker)
start_marker = ptr;
else if (*ptr == kLogEndMarker)
end_marker = ptr;
}
// Verify that start & end markers were found, somewhere, in-between
// this and the LogAssertHandler scope, in the LogMessage destructor's
// stack frame.
ASSERT_TRUE(start_marker);
ASSERT_TRUE(end_marker);
// Verify that the |message| is found in-between the markers.
const char* start_char_marker =
reinterpret_cast<char*>(start_marker + 1);
const char* end_char_marker = reinterpret_cast<char*>(end_marker);
const base::StringPiece stack_view(start_char_marker,
end_char_marker - start_char_marker);
ASSERT_FALSE(stack_view.find(message) == base::StringPiece::npos);
},
&stack_start));
// Trigger a log assertion, with a test message we can check for.
LOG(FATAL) << kTestMessage;
}
#endif // !defined(ADDRESS_SANITIZER)
} // namespace } // namespace
} // namespace logging } // namespace logging
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