New issue
Advanced search Search tips

Issue 709112 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

base::test::ScopedFeatureList can race uses of FeatureList on other threads

Project Member Reported by ellyjo...@chromium.org, Apr 6 2017

Issue description

For example, in this bot failure:

https://uberchromegw.corp.google.com/i/chromium.memory/builders/Linux%20TSan%20Tests/builds/3766

TSan finds a data race:

WARNING: ThreadSanitizer: data race (pid=7518)
  Write of size 8 at 0x000009704430 by main thread:
    #0 base::FeatureList::ClearInstanceForTesting() base/feature_list.cc:284:14 (content_browsertests+0x2c266a3)
    #1 base::test::ScopedFeatureList::InitWithFeatureList(std::__1::unique_ptr<base::FeatureList, std::__1::default_delete<base::FeatureList> >) base/test/scoped_feature_list.cc:53:28 (content_browsertests+0x274e016)
    #2 InitFromCommandLine base/test/scoped_feature_list.cc:62:3 (content_browsertests+0x274e257)
    #3 base::test::ScopedFeatureList::InitAndDisableFeature(base::Feature const&) base/test/scoped_feature_list.cc:70 (content_browsertests+0x274e257)
    #4 content::WebRtcGetUserMediaBrowserTest_TwoGetUserMediaWithFirstHdSecondVga_Test::RunTestOnMainThread() content/browser/webrtc/webrtc_getusermedia_browsertest.cc:562:23 (content_browsertests+0xa9bed7)
    #5 content::ContentBrowserTest::RunTestOnMainThreadLoop() content/public/test/content_browser_test.cc:138:3 (content_browsertests+0x270ff88)
    #6 content::BrowserTestBase::ProxyRunTestOnMainThreadLoop() content/public/test/browser_test_base.cc:346:5 (content_browsertests+0x271d385)
    #7 Invoke<content::BrowserTestBase *> base/bind_internal.h:214:12 (content_browsertests+0x271df45)
    #8 MakeItSo<void (content::BrowserTestBase::*const &)(), content::BrowserTestBase *> base/bind_internal.h:285 (content_browsertests+0x271df45)
    #9 RunImpl<void (content::BrowserTestBase::*const &)(), const std::__1::tuple<base::internal::UnretainedWrapper<content::BrowserTestBase> > &, 0> base/bind_internal.h:361 (content_browsertests+0x271df45)
    #10 base::internal::Invoker<base::internal::BindState<void (content::BrowserTestBase::*)(), base::internal::UnretainedWrapper<content::BrowserTestBase> >, void ()>::Run(base::internal::BindStateBase*) base/bind_internal.h:339 (content_browsertests+0x271df45)
    #11 Run base/callback.h:80:12 (content_browsertests+0x27abc71)
    #12 content::ShellBrowserMainParts::PreMainMessageLoopRun() content/shell/browser/shell_browser_main_parts.cc:196 (content_browsertests+0x27abc71)
    #13 content::BrowserMainLoop::PreMainMessageLoopRun() content/browser/browser_main_loop.cc:1156:13 (content_browsertests+0x1fc34f0)
    #14 Invoke<content::BrowserMainLoop *> base/bind_internal.h:214:12 (content_browsertests+0x1fc6695)
    #15 MakeItSo<int (content::BrowserMainLoop::*const &)(), content::BrowserMainLoop *> base/bind_internal.h:285 (content_browsertests+0x1fc6695)
    #16 RunImpl<int (content::BrowserMainLoop::*const &)(), const std::__1::tuple<base::internal::UnretainedWrapper<content::BrowserMainLoop> > &, 0> base/bind_internal.h:361 (content_browsertests+0x1fc6695)
    #17 base::internal::Invoker<base::internal::BindState<int (content::BrowserMainLoop::*)(), base::internal::UnretainedWrapper<content::BrowserMainLoop> >, int ()>::Run(base::internal::BindStateBase*) base/bind_internal.h:339 (content_browsertests+0x1fc6695)
    #18 Run base/callback.h:80:12 (content_browsertests+0x2491b9c)
    #19 content::StartupTaskRunner::RunAllTasksNow() content/browser/startup_task_runner.cc:45 (content_browsertests+0x2491b9c)
    #20 content::BrowserMainLoop::CreateStartupTasks() content/browser/browser_main_loop.cc:954:25 (content_browsertests+0x1fc12b3)
    #21 content::BrowserMainRunnerImpl::Initialize(content::MainFunctionParams const&) content/browser/browser_main_runner.cc:125:17 (content_browsertests+0x1fc6f56)
    #22 ShellBrowserMain(content::MainFunctionParams const&, std::__1::unique_ptr<content::BrowserMainRunner, std::__1::default_delete<content::BrowserMainRunner> > const&) content/shell/browser/shell_browser_main.cc:23:32 (content_browsertests+0x2787847)
    #23 content::ShellMainDelegate::RunProcess(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, content::MainFunctionParams const&) content/shell/app/shell_main_delegate.cc:297:16 (content_browsertests+0x277a033)
    #24 content::RunNamedProcessTypeMain(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, content::MainFunctionParams const&, content::ContentMainDelegate*) content/app/content_main_runner.cc:424:35 (content_browsertests+0x1eaf12b)
    #25 content::ContentMainRunnerImpl::Run() content/app/content_main_runner.cc:729:12 (content_browsertests+0x1eafc84)
    #26 content::ContentServiceManagerMainDelegate::Run() content/app/content_service_manager_main_delegate.cc:36:32 (content_browsertests+0xfaed3f)
    #27 service_manager::Main(service_manager::MainParams const&) services/service_manager/embedder/main.cc:179:25 (content_browsertests+0x40eb03c)
    #28 content::ContentMain(content::ContentMainParams const&) content/app/content_main.cc:19:10 (content_browsertests+0xfaee9b)
    #29 content::BrowserTestBase::SetUp() content/public/test/browser_test_base.cc:312:3 (content_browsertests+0x271cfff)
    #30 content::ContentBrowserTest::SetUp() content/public/test/content_browser_test.cc:94:20 (content_browsertests+0x270fe06)
    #31 content::WebRtcContentBrowserTestBase::SetUp() content/browser/webrtc/webrtc_content_browsertest_base.cc:46:23 (content_browsertests+0xa94e11)
    #32 HandleExceptionsInMethodIfSupported<testing::Test, void> testing/gtest/src/gtest.cc:2458:12 (content_browsertests+0x29be8f6)
    #33 testing::Test::Run() testing/gtest/src/gtest.cc:2470 (content_browsertests+0x29be8f6)
    #34 testing::TestInfo::Run() testing/gtest/src/gtest.cc:2656:11 (content_browsertests+0x29bf79d)
    #35 testing::TestCase::Run() testing/gtest/src/gtest.cc:2774:28 (content_browsertests+0x29bfee6)
    #36 testing::internal::UnitTestImpl::RunAllTests() testing/gtest/src/gtest.cc:4647:43 (content_browsertests+0x29cabe6)
    #37 HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> testing/gtest/src/gtest.cc:2458:12 (content_browsertests+0x29ca512)
    #38 testing::UnitTest::Run() testing/gtest/src/gtest.cc:4255 (content_browsertests+0x29ca512)
    #39 RUN_ALL_TESTS testing/gtest/include/gtest/gtest.h:2237:46 (content_browsertests+0x274e837)
    #40 base::TestSuite::Run() base/test/test_suite.cc:271 (content_browsertests+0x274e837)
    #41 content::ContentTestLauncherDelegate::RunTestSuite(int, char**) content/test/content_test_launcher.cc:105:48 (content_browsertests+0x2714d0b)
    #42 content::LaunchTests(content::TestLauncherDelegate*, int, int, char**) content/public/test/test_launcher.cc:520:31 (content_browsertests+0x273a64d)
    #43 main content/test/content_test_launcher.cc:131:10 (content_browsertests+0x2714c92)

  Previous read of size 8 at 0x000009704430 by thread T17:
    #0 base::FeatureList::IsEnabled(base::Feature const&) base/feature_list.cc:218:8 (content_browsertests+0x2c26246)
    #1 net::CertVerifyProc::CertVerifyProc() net/cert/cert_verify_proc.cc:523:32 (content_browsertests+0x36d18cb)
    #2 net::CertVerifyProcNSS::CertVerifyProcNSS() net/cert/cert_verify_proc_nss.cc:769:20 (content_browsertests+0x36d339d)
    #3 net::CertVerifyProc::CreateDefault() net/cert/cert_verify_proc.cc:506:14 (content_browsertests+0x36d1863)
    #4 net::CertVerifier::CreateDefault() net/cert/cert_verifier.cc:86:11 (content_browsertests+0x36812da)
    #5 content::ShellURLRequestContextGetter::GetURLRequestContext() content/shell/browser/shell_url_request_context_getter.cc:166:33 (content_browsertests+0x27b0625)
    #6 content::ChromeAppCacheService::InitializeOnIOThread(base::FilePath const&, content::ResourceContext*, net::URLRequestContextGetter*, scoped_refptr<storage::SpecialStoragePolicy>) content/browser/appcache/chrome_appcache_service.cc:44:49 (content_browsertests+0x1f7986c)
    #7 Invoke<const scoped_refptr<content::ChromeAppCacheService> &, const base::FilePath &, content::ResourceContext *const &, net::URLRequestContextGetter *, storage::SpecialStoragePolicy *> base/bind_internal.h:214:12 (content_browsertests+0x249ae3c)
    #8 MakeItSo<void (content::ChromeAppCacheService::*const &)(const base::FilePath &, content::ResourceContext *, net::URLRequestContextGetter *, scoped_refptr<storage::SpecialStoragePolicy>), const scoped_refptr<content::ChromeAppCacheService> &, const base::FilePath &, content::ResourceContext *const &, net::URLRequestContextGetter *, storage::SpecialStoragePolicy *> base/bind_internal.h:285 (content_browsertests+0x249ae3c)
    #9 RunImpl<void (content::ChromeAppCacheService::*const &)(const base::FilePath &, content::ResourceContext *, net::URLRequestContextGetter *, scoped_refptr<storage::SpecialStoragePolicy>), const std::__1::tuple<scoped_refptr<content::ChromeAppCacheService>, base::FilePath, content::ResourceContext *, base::internal::RetainedRefWrapper<net::URLRequestContextGetter>, base::internal::RetainedRefWrapper<storage::SpecialStoragePolicy> > &, 0, 1, 2, 3, 4> base/bind_internal.h:361 (content_browsertests+0x249ae3c)
    #10 base::internal::Invoker<base::internal::BindState<void (content::ChromeAppCacheService::*)(base::FilePath const&, content::ResourceContext*, net::URLRequestContextGetter*, scoped_refptr<storage::SpecialStoragePolicy>), scoped_refptr<content::ChromeAppCacheService>, base::FilePath, content::ResourceContext*, base::internal::RetainedRefWrapper<net::URLRequestContextGetter>, base::internal::RetainedRefWrapper<storage::SpecialStoragePolicy> >, void ()>::Run(base::internal::BindStateBase*) base/bind_internal.h:339 (content_browsertests+0x249ae3c)
    #11 Run base/callback.h:91:12 (content_browsertests+0x2cfbccc)
    #12 base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*) base/debug/task_annotator.cc:59 (content_browsertests+0x2cfbccc)
    #13 base::MessageLoop::RunTask(base::PendingTask*) base/message_loop/message_loop.cc:423:19 (content_browsertests+0x2c4b562)
    #14 base::MessageLoop::DeferOrRunPendingTask(base::PendingTask) base/message_loop/message_loop.cc:434:5 (content_browsertests+0x2c4bb2d)
    #15 base::MessageLoop::DoWork() base/message_loop/message_loop.cc:527:13 (content_browsertests+0x2c4c304)
    #16 base::MessagePumpLibevent::Run(base::MessagePump::Delegate*) base/message_loop/message_pump_libevent.cc:219:31 (content_browsertests+0x2c513e0)
    #17 base::MessageLoop::RunHandler() base/message_loop/message_loop.cc:387:10 (content_browsertests+0x2c4b04b)
    #18 base::RunLoop::Run() base/run_loop.cc:37:10 (content_browsertests+0x2c7a799)
    #19 base::Thread::Run(base::RunLoop*) base/threading/thread.cc:250:13 (content_browsertests+0x2cb1409)
    #20 content::BrowserThreadImpl::IOThreadRun(base::RunLoop*) content/browser/browser_thread_impl.cc:278:11 (content_browsertests+0x1fd42ff)
    #21 content::BrowserThreadImpl::Run(base::RunLoop*) content/browser/browser_thread_impl.cc:313:14 (content_browsertests+0x1fd4522)
    #22 base::Thread::ThreadMain() base/threading/thread.cc:333:3 (content_browsertests+0x2cb1654)
    #23 base::(anonymous namespace)::ThreadFunc(void*) base/threading/platform_thread_posix.cc:71:13 (content_browsertests+0x2ca9a6d)

  Location is global 'base::(anonymous namespace)::g_instance' of size 8 at 0x000009704430 (content_browsertests+0x000009704430)

  Thread T17 'Chrome_IOThread' (tid=7538, running) created by main thread at:
    #0 pthread_create <null> (content_browsertests+0x4bd055)
    #1 base::(anonymous namespace)::CreateThread(unsigned long, bool, base::PlatformThread::Delegate*, base::PlatformThreadHandle*, base::ThreadPriority) base/threading/platform_thread_posix.cc:110:13 (content_browsertests+0x2ca95f7)
    #2 base::PlatformThread::CreateWithPriority(unsigned long, base::PlatformThread::Delegate*, base::PlatformThreadHandle*, base::ThreadPriority) base/threading/platform_thread_posix.cc:191:10 (content_browsertests+0x2ca94f5)
    #3 base::Thread::StartWithOptions(base::Thread::Options const&) base/threading/thread.cc:112:15 (content_browsertests+0x2cb0f2f)
    #4 content::BrowserThreadImpl::StartWithOptions(base::Thread::Options const&) content/browser/browser_thread_impl.cc:404:25 (content_browsertests+0x1fd4b0a)
    #5 content::BrowserMainLoop::CreateThreads() content/browser/browser_main_loop.cc:1129:32 (content_browsertests+0x1fc2060)
    #6 Invoke<content::BrowserMainLoop *> base/bind_internal.h:214:12 (content_browsertests+0x1fc6695)
    #7 MakeItSo<int (content::BrowserMainLoop::*const &)(), content::BrowserMainLoop *> base/bind_internal.h:285 (content_browsertests+0x1fc6695)
    #8 RunImpl<int (content::BrowserMainLoop::*const &)(), const std::__1::tuple<base::internal::UnretainedWrapper<content::BrowserMainLoop> > &, 0> base/bind_internal.h:361 (content_browsertests+0x1fc6695)
    #9 base::internal::Invoker<base::internal::BindState<int (content::BrowserMainLoop::*)(), base::internal::UnretainedWrapper<content::BrowserMainLoop> >, int ()>::Run(base::internal::BindStateBase*) base/bind_internal.h:339 (content_browsertests+0x1fc6695)
    #10 Run base/callback.h:80:12 (content_browsertests+0x2491b9c)
    #11 content::StartupTaskRunner::RunAllTasksNow() content/browser/startup_task_runner.cc:45 (content_browsertests+0x2491b9c)
    #12 content::BrowserMainLoop::CreateStartupTasks() content/browser/browser_main_loop.cc:954:25 (content_browsertests+0x1fc12b3)
    #13 content::BrowserMainRunnerImpl::Initialize(content::MainFunctionParams const&) content/browser/browser_main_runner.cc:125:17 (content_browsertests+0x1fc6f56)
    #14 ShellBrowserMain(content::MainFunctionParams const&, std::__1::unique_ptr<content::BrowserMainRunner, std::__1::default_delete<content::BrowserMainRunner> > const&) content/shell/browser/shell_browser_main.cc:23:32 (content_browsertests+0x2787847)
    #15 content::ShellMainDelegate::RunProcess(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, content::MainFunctionParams const&) content/shell/app/shell_main_delegate.cc:297:16 (content_browsertests+0x277a033)
    #16 content::RunNamedProcessTypeMain(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, content::MainFunctionParams const&, content::ContentMainDelegate*) content/app/content_main_runner.cc:424:35 (content_browsertests+0x1eaf12b)
    #17 content::ContentMainRunnerImpl::Run() content/app/content_main_runner.cc:729:12 (content_browsertests+0x1eafc84)
    #18 content::ContentServiceManagerMainDelegate::Run() content/app/content_service_manager_main_delegate.cc:36:32 (content_browsertests+0xfaed3f)
    #19 service_manager::Main(service_manager::MainParams const&) services/service_manager/embedder/main.cc:179:25 (content_browsertests+0x40eb03c)
    #20 content::ContentMain(content::ContentMainParams const&) content/app/content_main.cc:19:10 (content_browsertests+0xfaee9b)
    #21 content::BrowserTestBase::SetUp() content/public/test/browser_test_base.cc:312:3 (content_browsertests+0x271cfff)
    #22 content::ContentBrowserTest::SetUp() content/public/test/content_browser_test.cc:94:20 (content_browsertests+0x270fe06)
    #23 content::WebRtcContentBrowserTestBase::SetUp() content/browser/webrtc/webrtc_content_browsertest_base.cc:46:23 (content_browsertests+0xa94e11)
    #24 HandleExceptionsInMethodIfSupported<testing::Test, void> testing/gtest/src/gtest.cc:2458:12 (content_browsertests+0x29be8f6)
    #25 testing::Test::Run() testing/gtest/src/gtest.cc:2470 (content_browsertests+0x29be8f6)
    #26 testing::TestInfo::Run() testing/gtest/src/gtest.cc:2656:11 (content_browsertests+0x29bf79d)
    #27 testing::TestCase::Run() testing/gtest/src/gtest.cc:2774:28 (content_browsertests+0x29bfee6)
    #28 testing::internal::UnitTestImpl::RunAllTests() testing/gtest/src/gtest.cc:4647:43 (content_browsertests+0x29cabe6)
    #29 HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> testing/gtest/src/gtest.cc:2458:12 (content_browsertests+0x29ca512)
    #30 testing::UnitTest::Run() testing/gtest/src/gtest.cc:4255 (content_browsertests+0x29ca512)
    #31 RUN_ALL_TESTS testing/gtest/include/gtest/gtest.h:2237:46 (content_browsertests+0x274e837)
    #32 base::TestSuite::Run() base/test/test_suite.cc:271 (content_browsertests+0x274e837)
    #33 content::ContentTestLauncherDelegate::RunTestSuite(int, char**) content/test/content_test_launcher.cc:105:48 (content_browsertests+0x2714d0b)
    #34 content::LaunchTests(content::TestLauncherDelegate*, int, int, char**) content/public/test/test_launcher.cc:520:31 (content_browsertests+0x273a64d)
    #35 main content/test/content_test_launcher.cc:131:10 (content_browsertests+0x2714c92)

SUMMARY: ThreadSanitizer: data race base/feature_list.cc:284:14 in base::FeatureList::ClearInstanceForTesting()

asvitkine@, ptal? :)
 
The scoped feature list probably needs to be initialized earlier in the test.

See a similar bug that was fixed here: https://bugs.chromium.org/p/chromium/issues/detail?id=663850

Please re-assign to the test owner to take a look.

Owner: guidou@chromium.org
guidou@, can you please take a look? :)
Project Member

Comment 3 by bugdroid1@chromium.org, Apr 7 2017

Project Member

Comment 4 by bugdroid1@chromium.org, Apr 8 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/270af5af87a83f24a120ac2417bc6ad0aafcca6f

commit 270af5af87a83f24a120ac2417bc6ad0aafcca6f
Author: guidou <guidou@chromium.org>
Date: Sat Apr 08 09:19:53 2017

Fix race in WebRtcGetUserMediaBrowserTest

Some test cases raced because each case was changing a global feature flag potentially in parallel.
Instead of having separate test cases that each set the flag, have separate tests objects for each
value of the flag, and set the flag in the constructor to avoid races.

BUG= 709112 
TBR=hbos@chromium.org

Review-Url: https://codereview.chromium.org/2808463004
Cr-Commit-Position: refs/heads/master@{#463130}

[modify] https://crrev.com/270af5af87a83f24a120ac2417bc6ad0aafcca6f/content/browser/webrtc/webrtc_getusermedia_browsertest.cc

Status: Fixed (was: Assigned)
Cc: guidou@chromium.org
 Issue 709559  has been merged into this issue.

Sign in to add a comment