Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1081)

Unified Diff: base/debug/proc_maps_linux_unittest.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/callback_list.h.pump ('k') | base/files/file_path.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/proc_maps_linux_unittest.cc
diff --git a/base/debug/proc_maps_linux_unittest.cc b/base/debug/proc_maps_linux_unittest.cc
index d5d1b835f4eb7081db6e81a285c676d49cde93dd..142f891845d3f43d41cd10ef01ede0761522ac02 100644
--- a/base/debug/proc_maps_linux_unittest.cc
+++ b/base/debug/proc_maps_linux_unittest.cc
@@ -7,6 +7,7 @@
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
+#include "base/threading/platform_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -197,6 +198,14 @@ TEST(ProcMapsTest, ReadProcMaps) {
bool found_exe = false;
bool found_stack = false;
bool found_address = false;
+
+ // Valgrind uses its own allocated stacks instead of the kernel-provided stack
+ // without letting the kernel know via prctl(PR_SET_MM_START_STACK). This
+ // causes the kernel to use [stack:TID] format. See http://crbug.com/431702
+ // for details.
+ std::string stack_with_tid =
+ StringPrintf("[stack:%d]", PlatformThread::CurrentId());
+
for (size_t i = 0; i < regions.size(); ++i) {
if (regions[i].path == exe_path.value()) {
// It's OK to find the executable mapped multiple times as there'll be
@@ -204,17 +213,23 @@ TEST(ProcMapsTest, ReadProcMaps) {
found_exe = true;
}
+ bool is_correct_stack = false;
if (regions[i].path == "[stack]") {
- // Only check if |address| lies within the real stack when not running
- // Valgrind, otherwise |address| will be on a stack that Valgrind creates.
- if (!RunningOnValgrind()) {
- EXPECT_GE(address, regions[i].start);
- EXPECT_LT(address, regions[i].end);
- }
+ is_correct_stack = true;
+ EXPECT_FALSE(RunningOnValgrind());
+ EXPECT_GE(address, regions[i].start);
+ EXPECT_LT(address, regions[i].end);
+ } else if (regions[i].path == stack_with_tid) {
+ is_correct_stack = true;
+ EXPECT_TRUE(RunningOnValgrind());
+ }
+ if (is_correct_stack) {
+ // Note that the stack is executable when it is created by Valgrind.
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::READ);
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::WRITE);
- EXPECT_FALSE(regions[i].permissions & MappedMemoryRegion::EXECUTE);
+ EXPECT_EQ(RunningOnValgrind(),
+ (regions[i].permissions & MappedMemoryRegion::EXECUTE) != 0);
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::PRIVATE);
EXPECT_FALSE(found_stack) << "Found duplicate stacks";
found_stack = true;
« no previous file with comments | « base/callback_list.h.pump ('k') | base/files/file_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698