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

Unified Diff: base/debug/proc_maps_linux_unittest.cc

Issue 760503002: Turn on stack use-after-return detection in non-official ASan builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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 | « no previous file | build/sanitizers/sanitizer_options.cc » ('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 c9f2267e166e15cdcf8241cee9f8b20d51f3ca86..5ac75569aa6e9c17782457fe044fa2818bbc9701 100644
--- a/base/debug/proc_maps_linux_unittest.cc
+++ b/base/debug/proc_maps_linux_unittest.cc
@@ -181,20 +181,19 @@ TEST(ProcMapsTest, Permissions) {
}
}
-TEST(ProcMapsTest, ReadProcMaps) {
- std::string proc_maps;
- ASSERT_TRUE(ReadProcMaps(&proc_maps));
-
- std::vector<MappedMemoryRegion> regions;
- ASSERT_TRUE(ParseProcMaps(proc_maps, &regions));
- ASSERT_FALSE(regions.empty());
-
+#if defined(ADDRESS_SANITIZER)
+// AddressSanitizer may move local variables to a dedicated "fake stack" which
+// is outside the stack region listed in /proc/self/maps. We disable ASan
+// instrumentation for this function to force the variable to be local.
+__attribute__((no_sanitize_address))
+#endif
+void CheckProcMapsRegions(const std::vector<MappedMemoryRegion> &regions) {
// We should be able to find both the current executable as well as the stack
// mapped into memory. Use the address of |proc_maps| as a way of finding the
earthdok 2014/12/02 17:45:26 s/proc_maps/exe_path/
Alexander Potapenko 2014/12/02 17:52:05 Good catch! Fixed.
// stack.
FilePath exe_path;
EXPECT_TRUE(PathService::Get(FILE_EXE, &exe_path));
- uintptr_t address = reinterpret_cast<uintptr_t>(&proc_maps);
+ uintptr_t address = reinterpret_cast<uintptr_t>(&exe_path);
bool found_exe = false;
bool found_stack = false;
bool found_address = false;
@@ -246,6 +245,17 @@ TEST(ProcMapsTest, ReadProcMaps) {
}
}
+TEST(ProcMapsTest, ReadProcMaps) {
+ std::string proc_maps;
+ ASSERT_TRUE(ReadProcMaps(&proc_maps));
+
+ std::vector<MappedMemoryRegion> regions;
+ ASSERT_TRUE(ParseProcMaps(proc_maps, &regions));
+ ASSERT_FALSE(regions.empty());
+
+ CheckProcMapsRegions(regions);
+}
+
TEST(ProcMapsTest, ReadProcMapsNonEmptyString) {
std::string old_string("I forgot to clear the string");
std::string proc_maps(old_string);
« no previous file with comments | « no previous file | build/sanitizers/sanitizer_options.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698