diff options
author | Mark Mentovai <mark@chromium.org> | 2019-04-26 14:00:01 -0400 |
---|---|---|
committer | Mark Mentovai <mark@chromium.org> | 2019-04-26 18:44:54 +0000 |
commit | 21b48a72aa50dde84149267f6b7402522b846b24 (patch) | |
tree | 41447920039676cbe4eaaad646ffac595f29b861 /src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc | |
parent | Linux MinidumpWriter: fix stack-use-after-scope violation (diff) | |
download | breakpad-21b48a72aa50dde84149267f6b7402522b846b24.tar.xz |
Linux breakpad_unittests: fix ThreadSanitizer problems
Some tests were failing because they had expectations about the number
of threads in a process, but TSan, and in some cases, ASan, introduce
their own threads. Where a sanitizer affects this, the expectations are
now used as minimum thread counts, not exact thread counts. See
https://www.brooklinen.com/blogs/brookliving/best-thread-count-for-sheets.
These problems were detected by ThreadSanitizer at
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8915151099544583616/+/steps/breakpad_unittests__with_patch_/0/stdout
Bug: chromium:949098
Change-Id: Ie40f1766bea27e9bcb112bf9e0b8b846fb343012
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1585948
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Diffstat (limited to 'src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc')
-rw-r--r-- | src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc index 3060327f..8757563e 100644 --- a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc @@ -434,10 +434,15 @@ TEST(LinuxPtraceDumperTest, VerifyStackReadWithMultipleThreads) { // Children are ready now. LinuxPtraceDumper dumper(child_pid); ASSERT_TRUE(dumper.Init()); - EXPECT_EQ((size_t)kNumberOfThreadsInHelperProgram, dumper.threads().size()); +#if defined(THREAD_SANITIZER) + EXPECT_GE(dumper.threads().size(), (size_t)kNumberOfThreadsInHelperProgram); +#else + EXPECT_EQ(dumper.threads().size(), (size_t)kNumberOfThreadsInHelperProgram); +#endif EXPECT_TRUE(dumper.ThreadsSuspend()); ThreadInfo one_thread; + size_t matching_threads = 0; for (size_t i = 0; i < dumper.threads().size(); ++i) { EXPECT_TRUE(dumper.GetThreadInfoByIndex(i, &one_thread)); const void* stack; @@ -465,8 +470,9 @@ TEST(LinuxPtraceDumperTest, VerifyStackReadWithMultipleThreads) { dumper.threads()[i], process_tid_location, 4); - EXPECT_EQ(dumper.threads()[i], one_thread_id); + matching_threads += (dumper.threads()[i] == one_thread_id) ? 1 : 0; } + EXPECT_EQ(matching_threads, kNumberOfThreadsInHelperProgram); EXPECT_TRUE(dumper.ThreadsResume()); kill(child_pid, SIGKILL); |