New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 719448 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug



Sign in to add a comment

Fetching histograms fails on another thread

Project Member Reported by pauljensen@chromium.org, May 8 2017

Issue description

$ git cl patch 2872593002
$ ./components/cronet/tools/cr_cronet.py build-test -f CronetUrlRequestContextTest#testGetGlobalMetricsDeltas

C    8.147s Main  [  PASSED  ] 0 tests.
C    8.147s Main  [  FAILED  ] 1 test, listed below:
C    8.147s Main  [  FAILED  ] org.chromium.net.CronetUrlRequestContextTest#testGetGlobalMetricsDeltas (CRASHED)

logcat shows:
I/DEBUG   (  194): Abort message: '[0508/121002.659275:FATAL:histogram_snapshot_manager.cc(38)] Check failed: thread_checker_.CalledOnValidThread().

This is blocking an internal process; would be preferred if it gets fixed before next dev channel release.
 
Note: reverting r462185 does not fix
Cc: bcwh...@chromium.org
Looks like crash is coming from r466760.

@bcwhite, can you explain more of the motivation for the ThreadChecker?  I don't see any motivation in the CL description.  Is the HistogramSnapshotManager thread-unsafe?  was the ThreadChecker added in an attempt to track down a problem or enforcing a requirement?  Could the ThreadChecker be removed?  Could it be replaced with locking?  I know locking goes against Chromium threading approach (https://chromium.googlesource.com/chromium/src/+/master/docs/design/threading.md) but Cronet has exposed an API for years that fetched histogram deltas and didn't require a single thread.
Correct, it is not thread-safe.  Concurrent access can cause corruption in the std::map data structures, something that we're seeing and don't know the cause.

I'll post-update the CL description.  My bad.

Cc: asvitk...@chromium.org
If you need multi-thread access...  I can move everything to a base class and then have both HistogramSnapshotManager and ThreadSafeHistogramSnapshotManager HistogramSnapshotManager, the former using thread-checker and the latter using a lock.
Components: Internals>Metrics
> If you need multi-thread access...

Yes, Cronet's API requires this.

> I can move everything to a base class and then have both HistogramSnapshotManager
> and ThreadSafeHistogramSnapshotManager HistogramSnapshotManager, the former using
> thread-checker and the latter using a lock.

SGTM, we'll switch to ThreadSafeHistogramSnapshotManager in cronet::HistogramManager.
I'm not a fan of adding extra complexity to the base code to supports this.

Is there a reason the Cronet code can't be changed to ensure it only uses the object from the same thread where it's created?
Cronet exposes a thread-safe synchronous API for querying histogram deltas. 
 Cronet doesn't place restrictions on what thread this API is called from:
https://cs.chromium.org/chromium/src/components/cronet/android/api/src/org/chromium/net/CronetEngine.java?rcl=b081a87e2df7e28ae9cef236fa29357236f09d9e&l=456
Looks like the calling code already ensures thread afety:

https://cs.chromium.org/chromium/src/components/cronet/histogram_manager.cc?type=cs

So ThreadChecker is probably too restrictive here. Maybe we can just remove it?
> Maybe we can just remove it?

SGTM, should be as easy as clicking the revert button.  It would be great if we can get this in ASAP so the next dev channel cut has it.
Project Member

Comment 11 by bugdroid1@chromium.org, May 9 2017

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

commit 947514553066c623a85712d05c3a01bd1bcbbffc
Author: bcwhite <bcwhite@chromium.org>
Date: Tue May 09 04:01:17 2017

Add concurrency check to HistogramSnapshotManager.

Using ThreadChecker causes problems when outside code is doing its
own synchronization between multiple calling threads so remove that
and add an atomic to do a run-time concurrency CHECK.  This will
likely be removed in the future once it's well assured that concurrent
access is not the cause of the corrupted data structures.

Also, make known_histograms_ member "const" as it should have been from
the beginning.

BUG= 719448 , 600717

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

[modify] https://crrev.com/947514553066c623a85712d05c3a01bd1bcbbffc/base/metrics/histogram_snapshot_manager.cc
[modify] https://crrev.com/947514553066c623a85712d05c3a01bd1bcbbffc/base/metrics/histogram_snapshot_manager.h

Cc: -bcwh...@chromium.org
Owner: bcwh...@chromium.org
Status: Fixed (was: Available)
Project Member

Comment 13 by bugdroid1@chromium.org, May 11 2017

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

commit 942900db95e432adabbb191d3709ad1be86b33ef
Author: pauljensen <pauljensen@chromium.org>
Date: Thu May 11 20:40:54 2017

[Cronet] Regression test for DCHECK when histograms read on another thread

BUG= 719448 

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_cronet_tester

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

[modify] https://crrev.com/942900db95e432adabbb191d3709ad1be86b33ef/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java

Sign in to add a comment