diff options
author | glider <glider@chromium.org> | 2014-12-02 11:03:09 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-02 19:04:25 +0000 |
commit | 136dc0bf75f9be7ae86c336005279b6dde4dee46 (patch) | |
tree | 90b18194e7ffc71c7f8c7eb793c06efec9d2ac47 /base/debug/proc_maps_linux_unittest.cc | |
parent | d407a1dd00a3342f06f518db4c14102d8206b3a4 (diff) | |
download | chromium_src-136dc0bf75f9be7ae86c336005279b6dde4dee46.zip chromium_src-136dc0bf75f9be7ae86c336005279b6dde4dee46.tar.gz chromium_src-136dc0bf75f9be7ae86c336005279b6dde4dee46.tar.bz2 |
Turn on stack use-after-return detection in non-official ASan builds.
BUG=390117
R=scherkus@chromium.org
TBR=earthdok@chromium.org,thakis@chromium.org
Review URL: https://codereview.chromium.org/760503002
Cr-Commit-Position: refs/heads/master@{#306429}
Diffstat (limited to 'base/debug/proc_maps_linux_unittest.cc')
-rw-r--r-- | base/debug/proc_maps_linux_unittest.cc | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/base/debug/proc_maps_linux_unittest.cc b/base/debug/proc_maps_linux_unittest.cc index c9f2267..cbc0dd0 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, ®ions)); - 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> ®ions) { // 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 + // mapped into memory. Use the address of |exe_path| as a way of finding the // 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, ®ions)); + 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); |