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

Issue 725661 link

Starred by 3 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

Non trivial number of AutoCloseableRouter finalizer exceptions

Project Member Reported by dskiba@chromium.org, May 23 2017

Issue description

Comment 1 by roc...@chromium.org, May 25 2017

Components: -Internals>Mojo Internals>Mojo>Bindings
Seems like it's worth tracking down and fixing. Leaked Routers -> leaked message pipe handles potentially -> leaked messages, and messages can be arbitrarily complex leaks (carrying yet other message pipes with yet more queued messages, etc.)

Cc: lhchavez@chromium.org
Labels: -Pri-3 M-63 Pri-2
Owner: roc...@chromium.org
Status: Assigned (was: Untriaged)
Can we assign someone to this? Getting external reports of perf issues (issue 749417)
Issue 749417 has been merged into this issue.
Owner: jcivelli@chromium.org
Jay, would you have some time to poke at this in the near future?
I'll look at it.
I am adding the allocation location of the AutoCloseableRouter in this CL:
https://chromium-review.googlesource.com/c/chromium/src/+/672005
That should hopefully help identify the offending AutoCloseableRouters.
Project Member

Comment 8 by bugdroid1@chromium.org, Sep 19 2017

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

commit 76f4984b228babeaee64be51c38221e5c7971f90
Author: Jay Civelli <jcivelli@google.com>
Date: Tue Sep 19 17:49:34 2017

Adding tracking of location for AutoCloseableRouter.

In order to make it easier to track down leaked AutoCloseableRouter,
adding the stacktrace of the allocation location of the leaked
AutoCloseableRouter.

Bug: 725661
Change-Id: Id5496c881747013a37a77e8e5127d4d78347e749
Reviewed-on: https://chromium-review.googlesource.com/672005
Reviewed-by: Ken Rockot <rockot@chromium.org>
Commit-Queue: Jay Civelli <jcivelli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502886}
[modify] https://crrev.com/76f4984b228babeaee64be51c38221e5c7971f90/mojo/public/java/bindings/src/org/chromium/mojo/bindings/AutoCloseableRouter.java

Issue 762403 has been merged into this issue.
Cc: ligim...@chromium.org grossmanj@google.com
And here is the stack:

java.lang.IllegalStateException: Warning: Router objects should be explicitly closed when no longer required otherwise you may leak handles.
at org.chromium.mojo.bindings.AutoCloseableRouter.finalize(AutoCloseableRouter.java:117)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:250)
at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:237)
at java.lang.Daemons$Daemon.run(Daemons.java:103)
at java.lang.Thread.run(Thread.java:764)

Caused by: java.lang.Exception: AutocloseableRouter allocated at:

at org.chromium.mojo.bindings.AutoCloseableRouter.<init>(AutoCloseableRouter.java:43)
at org.chromium.mojo.bindings.Interface$Manager.attachProxy(Interface.java:400)
at org.chromium.mojo.bindings.Interface$Manager.attachProxy(Interface.java:364)
at org.chromium.mojo.bindings.Interface$Manager.getInterfaceRequest(Interface.java:380)
at org.chromium.services.service_manager.InterfaceProvider.getInterface(InterfaceProvider.java:48)
at org.chromium.chrome.browser.AppIndexingUtil.getCopylessPasteInterface(AppIndexingUtil.java:147)
at org.chromium.chrome.browser.AppIndexingUtil.extractCopylessPasteMetadata(AppIndexingUtil.java:75)
at org.chromium.chrome.browser.ChromeTabbedActivity$2.onPageLoadFinished(ChromeTabbedActivity.java:1474)
at org.chromium.chrome.browser.tab.Tab.didFinishPageLoad(Tab.java:1562)
at org.chromium.chrome.browser.tab.TabWebContentsObserver.didFinishLoad(TabWebContentsObserver.java:144)
at org.chromium.content.browser.webcontents.WebContentsObserverProxy.didFinishLoad(WebContentsObserverProxy.java:169)
at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:52)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6535)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Cc: wychen@chromium.org dproctor@google.com
Saw this last stack trace just by launching a local build of chrome_modern_apk_incremental. +CC wychen, dproctor (authors of AppIndexingUtil)
Cc: -wychen@chromium.org -dproctor@google.com jcivelli@chromium.org
Owner: wychen@chromium.org
dproctor@ is no longer on this project.
Quote from https://chromium-review.googlesource.com/c/chromium/src/+/775476/1/chrome/android/java/src/org/chromium/chrome/browser/AppIndexingUtil.java#79 by Ted:

I wonder if there are mojo changes we should investigate to support things like AutoCloseable or something to make this less error prone in the future.  Since this is only closed after the async task completes, there isn't really a path where AutoCloseable would make since.  Just something we should see if we can introduce some nicer patterns.

nyquist@ has a patch to support automatically deleting native counterparts when the java side is GC'd:
https://chromium-review.googlesource.com/c/chromium/src/+/704180

I'd prefer to find a way to enforce and explicit close vs relying on GC magic, but that's a hard thing to force in java.
Project Member

Comment 15 by bugdroid1@chromium.org, Nov 17 2017

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

commit 602dee256a3b07da9aa5226abef453dbb03b3d42
Author: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Date: Fri Nov 17 06:15:00 2017

Close the mojo pipe for AppIndexing after job is done

Bug: 725661
Change-Id: I29d98e6c022ca96de11dce35bc521307a24ce3d1
Reviewed-on: https://chromium-review.googlesource.com/775476
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: Jay Civelli <jcivelli@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517323}
[modify] https://crrev.com/602dee256a3b07da9aa5226abef453dbb03b3d42/chrome/android/java/src/org/chromium/chrome/browser/AppIndexingUtil.java
[modify] https://crrev.com/602dee256a3b07da9aa5226abef453dbb03b3d42/chrome/android/junit/src/org/chromium/chrome/browser/AppIndexingUtilTest.java

Cc: -roc...@chromium.org rockot@google.com
Cc: -lhchavez@chromium.org

Sign in to add a comment