New issue
Advanced search Search tips

Issue 799589 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 812600
Owner:
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

webkit_unit_tests CSSFontFaceSourceTest.UnboundedGrowth fails with MSVC and DCHECKs enabled

Project Member Reported by r...@chromium.org, Jan 5 2018

Issue description

I think this is actually a true positive bug that could lead to crashes in production if the table is resized during pruning. We don't seem to have coverage of these tests in this configuration on the CQ, so nobody noticed.

This is the code in question:

  scoped_refptr<SimpleFontData>& font_data =
      font_data_table_.insert(key, nullptr).stored_value->value;
  if (!font_data)
    font_data = CreateFontData(font_description, font_selection_capabilities);

  font_cache_key_age.PrependOrMoveToFirst(key);
  PruneOldestIfNeeded(); // modifies font_data_table_

wtf::HashTable has a pretty neat DCHECK to protect against dangling iterators pointing into the table after modification. The result of the '.insert()' call is such an iterator. MSVC lifetime extends it to the entire scope, but clang does not.

If the iterator is lifetime extended, it gets destroyed *after* the PruneOldestIfNeeded() call, and it always asserts in DCHECK-enabled build modes. You can reproduce the issue with clang if you rewrite the code like so:

  // tmp will live until after pruning and assert during cleanup
  auto tmp = font_data_table_.insert(key, nullptr);
  scoped_refptr<SimpleFontData>& font_data = tmp.stored_value->value;

|font_data| is a reference into the table, so if the table is rehashed, it will dangle. We should copy the scoped_refptr earlier and let NRVO elide the copy that would normally take place in the return. I'll put together a CL.
 
Correct, we don't actually run the tests in a MSVC build either in the CQ or on the chromium.win waterfalls.

Comment 2 by r...@chromium.org, Jan 5 2018

Fix: https://chromium-review.googlesource.com/852531

Dirk, oh, I thought win-msvc ran tests, but win-dbg did not. I see I was mistaken.

Just doing compilation isn't really enough to make sure that MSVC-built chrome really works. People are hitting use-after-move all the time, see the discussion about it on chromium-dev. I would at least want to run the tests in release mode, maybe just on chromium.win if the CQ doesn't have the capacity to run tests there.
Yup, that seems like a good thing to do.
Labels: Test-Functional
Labels: Stability-Crash

Comment 6 by r...@chromium.org, Feb 15 2018

Mergedinto: 812600
Status: Duplicate (was: Started)

Sign in to add a comment