Fetching histograms fails on another thread |
|||||
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.
,
May 8 2017
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.
,
May 8 2017
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.
,
May 8 2017
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.
,
May 8 2017
,
May 8 2017
> 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.
,
May 8 2017
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?
,
May 8 2017
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
,
May 8 2017
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?
,
May 9 2017
> 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.
,
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
,
May 9 2017
,
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 |
|||||
Comment 1 by pauljensen@chromium.org
, May 8 2017