Commit 4db886a0 authored by Olivier Li's avatar Olivier Li Committed by Commit Bot

Fix crashes in Sync related to unallowed uses of sync primitives on the ThreadPool.

Bug: 1023801
Change-Id: I2db91fc9d6979fe503ee761b955cd1756bdfbddc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1912882
Auto-Submit: Oliver Li <olivierli@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714906}
parent 158df85c
...@@ -214,6 +214,8 @@ class FinancialPing; ...@@ -214,6 +214,8 @@ class FinancialPing;
} }
namespace syncer { namespace syncer {
class GetLocalChangesRequest; class GetLocalChangesRequest;
class HttpBridge;
class ModelSafeWorker;
} }
namespace ui { namespace ui {
class CommandBufferClientImpl; class CommandBufferClientImpl;
...@@ -422,7 +424,9 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitives { ...@@ -422,7 +424,9 @@ class BASE_EXPORT ScopedAllowBaseSyncPrimitives {
friend class rlz_lib::FinancialPing; friend class rlz_lib::FinancialPing;
friend class shell_integration_linux:: friend class shell_integration_linux::
LaunchXdgUtilityScopedAllowBaseSyncPrimitives; LaunchXdgUtilityScopedAllowBaseSyncPrimitives;
friend class syncer::HttpBridge;
friend class syncer::GetLocalChangesRequest; friend class syncer::GetLocalChangesRequest;
friend class syncer::ModelSafeWorker;
friend class webrtc::DesktopConfigurationMonitor; friend class webrtc::DesktopConfigurationMonitor;
// Usage that should be fixed: // Usage that should be fixed:
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h" #include "base/values.h"
namespace syncer { namespace syncer {
...@@ -115,7 +116,10 @@ SyncerError ModelSafeWorker::DoWorkAndWaitUntilDone(WorkCallback work) { ...@@ -115,7 +116,10 @@ SyncerError ModelSafeWorker::DoWorkAndWaitUntilDone(WorkCallback work) {
// Unblocked when the task runs or is deleted or when RequestStop() is called // Unblocked when the task runs or is deleted or when RequestStop() is called
// before the task starts running. // before the task starts running.
work_done_or_abandoned_.Wait(); {
base::ScopedAllowBaseSyncPrimitives allow_wait;
work_done_or_abandoned_.Wait();
}
return did_run ? error : SyncerError(SyncerError::CANNOT_DO_WORK); return did_run ? error : SyncerError(SyncerError::CANNOT_DO_WORK);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "components/sync/base/cancelation_signal.h" #include "components/sync/base/cancelation_signal.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
...@@ -199,7 +200,10 @@ bool HttpBridge::MakeSynchronousPost(int* net_error_code, ...@@ -199,7 +200,10 @@ bool HttpBridge::MakeSynchronousPost(int* net_error_code,
// Block until network request completes or is aborted. See // Block until network request completes or is aborted. See
// OnURLFetchComplete and Abort. // OnURLFetchComplete and Abort.
http_post_completed_.Wait(); {
base::ScopedAllowBaseSyncPrimitives allow_wait;
http_post_completed_.Wait();
}
base::AutoLock lock(fetch_state_lock_); base::AutoLock lock(fetch_state_lock_);
DCHECK(fetch_state_.request_completed || fetch_state_.aborted); DCHECK(fetch_state_.request_completed || fetch_state_.aborted);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment