Skip to content

Commit 5541255

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm] Fix data race over file timeline recorder's cached blocks.
TEST=tsan Bug: #61475 Bug: #61796 Change-Id: I6995b00b47c3d67a7ea0a4a0e7d72509058ee392 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458060 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 066efcf commit 5541255

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

runtime/vm/timeline.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,28 +2215,23 @@ void TimelineEventFileRecorderBase::ShutDown() {
22152215

22162216
TimelineEventBlock* TimelineEventFileRecorderBase::GetNewBlockLocked() {
22172217
ASSERT(lock_.IsOwnedByCurrentThread());
2218-
// Start by reusing a block.
22192218
TimelineEventBlock* block = nullptr;
2220-
if (empty_blocks_ != nullptr) {
2221-
// TODO(vegorov) maybe we don't want to take a lock just to grab an empty
2222-
// block?
2219+
{
22232220
MonitorLocker ml(&monitor_);
22242221
if (empty_blocks_ != nullptr) {
22252222
block = empty_blocks_;
22262223
empty_blocks_ = empty_blocks_->next();
2227-
if (FLAG_trace_timeline) {
2228-
OS::PrintErr("Reused empty block %p\n", block);
2229-
}
22302224
}
22312225
}
22322226
if (block == nullptr) {
22332227
block = new TimelineEventBlock(block_count_++);
22342228
if (FLAG_trace_timeline) {
22352229
OS::PrintErr("Created new block %p\n", block);
22362230
}
2231+
} else if (FLAG_trace_timeline) {
2232+
OS::PrintErr("Reused empty block %p\n", block);
22372233
}
22382234
block->Open();
2239-
22402235
return block;
22412236
}
22422237

0 commit comments

Comments
 (0)