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

Issue 686458 link

Starred by 6 users

Issue metadata

Status: Fixed
Owner:
Android MediaRouter only (left Chro...
Closed: Feb 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 1
Type: Bug



Sign in to add a comment

Crash in blink::ElementVisibilityObserver::stop

Project Member Reported by ClusterFuzz, Jan 28 2017

Issue description

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=4802561975779328

Fuzzer: inferno_layout_test_unmodified
Job Type: mac_asan_content_shell
Platform Id: mac

Crash Type: UNKNOWN READ
Crash Address: 0x000000000010
Crash State:
  blink::ElementVisibilityObserver::stop
  blink::HTMLMediaElement::onVisibilityChangedForAutoplay
  blink::ElementVisibilityObserver::onVisibilityChanged
  
Sanitizer: address (ASAN)

Regressed: https://cluster-fuzz.appspot.com/revisions?job=mac_asan_content_shell&range=434473:434476

Minimized Testcase (150.06 Kb): https://cluster-fuzz.appspot.com/download/AMIfv97HOxznrs62wRFP4tIGB97lmiHlJRiQsj9zPikDHWh7w4v0Q99oJ-xVW6-c-0HICYVptYJHv4YkPNBJzeQsMi2WxZI_UNNu1RFuQThAKD1yWlgQhjUixgCb6-CXF54iEZcBpjZHbfNRDSt-p4ZzAhVR75RnYHSiOkVrD-VkfWWWdfa-Aps?testcase_id=4802561975779328

Issue filed automatically.

See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.
 

Comment 1 by tkent@chromium.org, Jan 30 2017

Components: Blink>Layout
Cc: ojan@chromium.org szager@chromium.org zqzh...@chromium.org mlamouri@chromium.org
Labels: Test-Predator-Wrong M-58
Based on  issue 656494 , c-ing few devs. could domeone look into this issue?
Thank you.
Cc: e...@chromium.org
Cc: -mlamouri@chromium.org msrchandra@chromium.org
Components: Blink>MemoryAllocator
Owner: mlamouri@chromium.org
Status: Assigned (was: Untriaged)
Predator and CL did not provide any possible suspects.
Using Code Search for the file, "ElementVisibilityObserver.cpp" assigning to the concern owner.
Suspecting Commit#
https://chromium.googlesource.com/chromium/src/+/10fecf4ab18ee7f481d25ae31122bb099c9b7039

@mlamouri -- Could you please look into the issue, kindly re-assign if this is not related to your changes.
Thank You.
Cc: -zqzh...@chromium.org mlamouri@chromium.org
Owner: zqzh...@chromium.org
I'll take a initial look as mlamouri@ is at BlinkOn
I'm seeing HTMLMediaElement::onVisibilityChangedForAutoplay() is called after we stop the ElementVisibilityObserver(), i.e. visibility change can still be fired after IntersectionObserver::Stop().

szager@, is this possible?

A quick fix is to just add a null check in HTMLMediaElement::onVisibilityChangedForAutoplay()
That should not be possible, I'd be very curious to see how that could happen.
It is actually possible. Found this: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp?rcl=bbf5af70f469a5f7807ec4573a65c3710cfbb29a&l=35

IntersectionObserverController::postTaskToDeliverObservations() posts a delayed task, which eventually reaches HTMLMediaElement::onVisibilityChangedForAutoplay().

If IntersectionObserver::stop() is called before the delayed task to execute, then we can reach this crash.

Do you think I should go with the quick fix in #6?
Ah, I see you're right; I thought that IntersectionObserver::disconnect() would throw away its pending notifications, but it doesn't (I think that's a recent change).

So, yes, the null-check is the right thing to do.
I'm slightly concerned about this:

https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/ElementVisibilityObserver.cpp?rcl=d2b7ed2ef23c46cce1d041ab2763132ca435a7bc&l=31

Is wrapWeakPersistent the right thing to do here?  Is it guaranteed that the ElementVisibilityObserver won't be gc-ed before IntersectionObserver::deliver runs?
It is possible. However when it happens, there's no need to deliver the observation to ElementVisibilityObserver, as the element it is observing is also gc-ed, i.e. the client doesn't need the observation anymore.

Also this will be safe as the closure created by WTF::bind will be cancelled when ElementVisibilityObserver is gc-ed:
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/heap/PersistentTest.cpp?q=wrapweakpersistent&sq=package:chromium&dr=C&l=27
Project Member

Comment 12 by bugdroid1@chromium.org, Feb 7 2017

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

commit 0268543786283db4107d2362f338901d909545b1
Author: zqzhang <zqzhang@chromium.org>
Date: Tue Feb 07 16:25:19 2017

[Blink>Media] Fix a crash in autoplay caused by delayed visibility observation

There is a crash caused by delayed visibility observation after an
autoplay muted video gets unmuted, so that HTMLMediaElement tries to
stop the observer twice. However the pointer to the observer is set to
null on stop, thus a crash happens.

This CL adds null-check in
HTMLMediaElement::onVisibilityChangedForAutoplay() to avoid the crash.

BUG= 686458 

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

[modify] https://crrev.com/0268543786283db4107d2362f338901d909545b1/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Comment 14 by ojan@chromium.org, Feb 7 2017

Should IntersectionObserver::disconnect throw away pending notifications? For the same reasons that we want it do, presumably web devs would too, right?
I agree. We should probably fix it in M58, but I prefer to merge the temporary fix to M57 as it is very small.
I see szager's new CL on IntersectionObserver is very short, maybe I revert my CL and merge the new one? Then we need to add a DCHECK() in HTMLMediaElement::onVisibilityChangedForAutoplay().
sgtm 👍
Project Member

Comment 18 by bugdroid1@chromium.org, Feb 7 2017

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

commit a00cedc6b6caf3fdf88bba8f4dba6b6fcda64a3e
Author: zqzhang <zqzhang@chromium.org>
Date: Tue Feb 07 20:47:49 2017

Revert of [Blink>Media] Fix a crash in autoplay caused by delayed visibility observation (patchset #1 id:1 of https://codereview.chromium.org/2671993002/ )

Reason for revert:
Decided to fix the issue in IntersectionObserver instead of HTMLMediaElement. This CL will be reverted and be superseded by the new fix.

Original issue's description:
> [Blink>Media] Fix a crash in autoplay caused by delayed visibility observation
>
> There is a crash caused by delayed visibility observation after an
> autoplay muted video gets unmuted, so that HTMLMediaElement tries to
> stop the observer twice. However the pointer to the observer is set to
> null on stop, thus a crash happens.
>
> This CL adds null-check in
> HTMLMediaElement::onVisibilityChangedForAutoplay() to avoid the crash.
>
> BUG= 686458 
>
> Review-Url: https://codereview.chromium.org/2671993002
> Cr-Commit-Position: refs/heads/master@{#448641}
> Committed: https://chromium.googlesource.com/chromium/src/+/0268543786283db4107d2362f338901d909545b1

TBR=mlamouri@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 686458 

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

[modify] https://crrev.com/a00cedc6b6caf3fdf88bba8f4dba6b6fcda64a3e/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Project Member

Comment 20 by sheriffbot@chromium.org, Feb 8 2017

Labels: -Merge-Request-57 Hotlist-Merge-Review Merge-Review-57
This bug requires manual review: Reverts referenced in bugdroid comments after merge request.
Please contact the milestone owner if you have questions.
Owners: amineer@(clank), cmasso@(bling), ketakid@(cros), govind@(desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 21 by ClusterFuzz, Feb 9 2017

ClusterFuzz has detected this issue as fixed in range 448729:448967.

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=4802561975779328

Fuzzer: inferno_layout_test_unmodified
Job Type: mac_asan_content_shell
Platform Id: mac

Crash Type: UNKNOWN READ
Crash Address: 0x000000000010
Crash State:
  blink::ElementVisibilityObserver::stop
  blink::HTMLMediaElement::onVisibilityChangedForAutoplay
  blink::ElementVisibilityObserver::onVisibilityChanged
  
Sanitizer: address (ASAN)

Regressed: https://cluster-fuzz.appspot.com/revisions?job=mac_asan_content_shell&range=434473:434476
Fixed: https://cluster-fuzz.appspot.com/revisions?job=mac_asan_content_shell&range=448729:448967

Reproducer Testcase: https://cluster-fuzz.appspot.com/download/AMIfv97HOxznrs62wRFP4tIGB97lmiHlJRiQsj9zPikDHWh7w4v0Q99oJ-xVW6-c-0HICYVptYJHv4YkPNBJzeQsMi2WxZI_UNNu1RFuQThAKD1yWlgQhjUixgCb6-CXF54iEZcBpjZHbfNRDSt-p4ZzAhVR75RnYHSiOkVrD-VkfWWWdfa-Aps?testcase_id=4802561975779328


See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.

If you suspect that the result above is incorrect, try re-doing that job on the test case report page.
Project Member

Comment 22 by ClusterFuzz, Feb 9 2017

Labels: ClusterFuzz-Verified
Status: Verified (was: Assigned)
ClusterFuzz testcase 4802561975779328 is verified as fixed, so closing issue.

If this is incorrect, please add ClusterFuzz-Wrong label and re-open the issue.
Labels: ClusterFuzz-Wrong
Status: Started (was: Verified)
We need to merge the fix (the last CL that szager landed) so reopen the issue now.
Before we approve merge to M57, could you please confirm CL by szager@ at #19 is well baked/verified in Canary and safe to merge to M57?
This change is very safe, no problems in canary
Labels: -Merge-Review-57 Merge-Approved-57
Approving merge for CL listed at #19 to M57 branch 2987 based on comment #25. Please merge ASAP. Thank you.
FYI It is merged at https://chromium.googlesource.com/chromium/src.git/+/13865a9236319d7ac82c2e61ccaa76f1c7225232

However there's no automatic message posted here yet. Will manually modify the merge tag if it doesn't happen in a few hours.
Labels: -Merge-Approved-57 merge-merged-2987
Per comment #27, this is already merged to M57. 
Status: Fixed (was: Started)
Issue 695390 has been merged into this issue.
Labels: -ClusterFuzz-Wrong
We have made a bunch of changes on ClusterFuzz side, so resetting ClusterFuzz-Wrong label.

Sign in to add a comment