Commit cdb207e6 authored by Mike Wittman's avatar Mike Wittman Committed by Commit Bot

[Sampling profiler] Avoid metadata read lock assertion

The assertion is implemented with DCHECK so is non-reentrant. It cannot
be safely invoked from the GetItems() functions since they are invoked
while the target thread is suspended. Independent of that the assertion
does not work in general on Android because the checking done by
base::Lock::AssertAcquired() is too restrictive.

Bug: 1004855
Change-Id: Ia2b390283844adf640077e7ee34650bf610cca09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225784
Commit-Queue: Mike Wittman <wittman@chromium.org>
Reviewed-by: default avatarEtienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774841}
parent bc43181c
......@@ -113,15 +113,10 @@ MetadataRecorder::MetadataProvider::~MetadataProvider() = default;
size_t MetadataRecorder::MetadataProvider::GetItems(
ItemArray* const items) const {
// Assertion is only necessary so that thread annotations recognize that
// |read_lock_| is acquired.
metadata_recorder_->read_lock_.AssertAcquired();
return metadata_recorder_->GetItems(items);
}
size_t MetadataRecorder::GetItems(ItemArray* const items) const {
read_lock_.AssertAcquired();
// If a writer adds a new item after this load, it will be ignored. We do
// this instead of calling item_slots_used_.load() explicitly in the for loop
// bounds checking, which would be expensive.
......
......@@ -187,8 +187,10 @@ class BASE_EXPORT MetadataRecorder {
// Retrieves the first |available_slots| items in the metadata recorder and
// copies them into |items|, returning the number of metadata items that
// were copied. To ensure that all items can be copied, |available slots|
// should be greater than or equal to |MAX_METADATA_COUNT|.
size_t GetItems(ItemArray* const items) const;
// should be greater than or equal to |MAX_METADATA_COUNT|. Requires
// NO_THREAD_SAFETY_ANALYSIS because clang's analyzer doesn't understand the
// cross-class locking used in this class' implementation.
size_t GetItems(ItemArray* const items) const NO_THREAD_SAFETY_ANALYSIS;
private:
const MetadataRecorder* const metadata_recorder_;
......
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