Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 6.0 Heap dump parsing failure #267

Closed
Exaper opened this issue Sep 1, 2015 · 51 comments
Closed

Android 6.0 Heap dump parsing failure #267

Exaper opened this issue Sep 1, 2015 · 51 comments
Milestone

Comments

@Exaper
Copy link

Exaper commented Sep 1, 2015

This happens on both: 1.3.1 and 1.4-SNAPSHOT

* FAILURE:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
        at com.squareup.leakcanary.HeapAnalyzer.findLeakingReference(HeapAnalyzer.java:160)
        at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:95)
        at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:57)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.os.HandlerThread.run(HandlerThread.java:61)
* Reference Key: 88f1eda2-7ddd-46df-a20b-7fb23672bc08
* Device: htc google Nexus 9 volantis
* Android Version: 6.0 API: 23 LeakCanary: 1.3.1
@pyricau
Copy link
Member

pyricau commented Sep 2, 2015

Can you provide me with the stacktrace for 1.4-SNAPSHOT? The entire implementation has changed, I need to know the correct line numbers.

@Exaper
Copy link
Author

Exaper commented Sep 3, 2015

@pyricau here you go:

* FAILURE:
java.lang.IllegalArgumentException: Field offset does not exists
        at com.squareup.leakcanary.HahaHelper.fieldValue(HahaHelper.java:143)
        at com.squareup.leakcanary.HahaHelper.asString(HahaHelper.java:81)
        at com.squareup.leakcanary.HeapAnalyzer.findLeakingReference(HeapAnalyzer.java:97)
        at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:79)
        at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:59)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.os.HandlerThread.run(HandlerThread.java:61)
* Reference Key: 526bde0a-769c-4578-ae67-380367e9c353
* Device: htc google Nexus 9 volantis
* Android Version: 6.0 API: 23 LeakCanary: 1.4-SNAPSHOT 6c0bee2
* Durations: watch=5018ms, gc=324ms, heap dump=5977ms, analysis=6107ms
* Excluded Refs:
| Field: android.view.textservice.SpellCheckerSession$1.this$0
| Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
| Static field: com.google.android.chimera.container.a.a
| Thread:FinalizerWatchdogDaemon (always)
| Thread:main (always)
| Thread:LeakCanary-Heap-Dump (always)
| Class:java.lang.ref.WeakReference (always)
| Class:java.lang.ref.SoftReference (always)
| Class:java.lang.ref.PhantomReference (always)
| Class:java.lang.ref.Finalizer (always)
| Class:java.lang.ref.FinalizerReference (always)

@kylefowler
Copy link

Also seeing this one

* FAILURE:
    java.lang.IllegalArgumentException: Field offset does not exists
            at com.squareup.leakcanary.HahaHelper.fieldValue(HahaHelper.java:143)
            at com.squareup.leakcanary.HahaHelper.asString(HahaHelper.java:81)
            at com.squareup.leakcanary.HeapAnalyzer.findLeakingReference(HeapAnalyzer.java:97)
            at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:79)
            at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:59)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.os.HandlerThread.run(HandlerThread.java:61)
    * Reference Key: 0c37f4d7-c1ca-4162-9827-669035c75399
    * Device: motorola google Nexus 6 shamu
    * Android Version: 6.0 API: 23 LeakCanary: 1.4-SNAPSHOT 6c0bee2
    * Durations: watch=5014ms, gc=154ms, heap dump=8525ms, analysis=40402ms
    * Excluded Refs:
    | Field: android.view.textservice.SpellCheckerSession$1.this$0
    | Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
    | Static field: com.google.android.chimera.container.a.a
    | Static field: com.facebook.stetho.inspector.elements.android.ActivityTracker.sInstance
    | Thread:FinalizerWatchdogDaemon (always)
    | Thread:main (always)
    | Thread:LeakCanary-Heap-Dump (always)
    | Class:java.lang.ref.WeakReference (always)
    | Class:java.lang.ref.SoftReference (always)
    | Class:java.lang.ref.PhantomReference (always)
    | Class:java.lang.ref.Finalizer (always)
    | Class:java.lang.ref.FinalizerReference (always)

@Exaper
Copy link
Author

Exaper commented Sep 10, 2015

@kylefowler got this one too. Could you confirm it happens on Marshmallow only?

@Exaper Exaper changed the title Heap dump parsing failure Android 6.0 Heap dump parsing failure Sep 10, 2015
@kylefowler
Copy link

yeah, only seeing it on M

@jacobmattsson
Copy link

@pyricau Any progress on this (six weeks since last activity)? LeakCanary seems unusable on Marshmallow (even with 1.4-SNAPSHOT). Is there any workaround? Saw your talk on Droidcon NYC and thought I'd give it a try ... Thanks!

@brianchu
Copy link

brianchu commented Nov 4, 2015

+1

@renclav
Copy link

renclav commented Nov 4, 2015

+1
In case it helps:

//For retrolambda
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

compileSdkVersion 23
buildToolsVersion '23.0.1'

defaultConfig {
    minSdkVersion 15

//Avoid applying new permission model for now, only one man ;)
targetSdkVersion 22
versionCode 800066
versionName "1.7.1"
resConfigs "en"
applicationId "********"
multiDexEnabled true
}

@Blahartinger
Copy link

+1 just found out about this tool and was excited to use it, but since I'm on M I get this error every time :(

@Jacksgong
Copy link

  • Android M
  • Nexus 5
  • targetSdkVersion 23
  • compileSdkVersion 23
  • multiDexEnabled true
11-09 14:23:12.014 E/AndroidRuntime( 3183): Process: com.liulishuo.engzo:leakcanary, PID: 3183
11-09 14:23:12.014 E/AndroidRuntime( 3183): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
11-09 14:23:12.014 E/AndroidRuntime( 3183):     at com.squareup.leakcanary.HeapAnalyzer.findLeakingReference(HeapAnalyzer.java:154)
11-09 14:23:12.014 E/AndroidRuntime( 3183):     at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:89)
11-09 14:23:12.014 E/AndroidRuntime( 3183):     at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:56)
11-09 14:23:12.014 E/AndroidRuntime( 3183):     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
11-09 14:23:12.014 E/AndroidRuntime( 3183):     at android.os.Handler.dispatchMessage(Handler.java:102)
11-09 14:23:12.014 E/AndroidRuntime( 3183):     at android.os.Looper.loop(Looper.java:148)
11-09 14:23:12.014 E/AndroidRuntime( 3183):     at android.os.HandlerThread.run(HandlerThread.java:61)

@Jacksgong
Copy link

  • Android M
  • Nexus 5
  • targetSdkVersion 23
  • compileSdkVersion 23
  • multiDexEnabled true

Crash every day:

1.3.1:

 if (/** npe here!!!! **/keyCandidate.equals(key)) {
        return (IObject) weakRef.resolveValue("referent");
      }

Detail:

// HeapAnalyzer#findLeakingReference by 1.3.1
private IObject findLeakingReference(String key, ISnapshot snapshot) throws SnapshotException {
    Collection<IClass> refClasses =
        snapshot.getClassesByName(KeyedWeakReference.class.getName(), false);

    if (refClasses.size() != 1) {
      throw new IllegalStateException(
          "Expecting one class for " + KeyedWeakReference.class.getName() + " in " + refClasses);
    }

    IClass refClass = refClasses.iterator().next();

    int[] weakRefInstanceIds = refClass.getObjectIds();

    for (int weakRefInstanceId : weakRefInstanceIds) {
      IObject weakRef = snapshot.getObject(weakRefInstanceId);
      String keyCandidate =
          PrettyPrinter.objectAsString((IObject) weakRef.resolveValue("key"), 100);
      if (/** npe here **/keyCandidate.equals(key)) {
        return (IObject) weakRef.resolveValue("referent");
      }
    }
    throw new IllegalStateException("Could not find weak reference with key " + key);
  }

// PrettyPrinter.objectAsString by 1.3.1
public static String objectAsString(IObject stringObject, int limit) throws SnapshotException {
    Integer count = (Integer) stringObject.resolveValue("count"); 
    if (count == null) return null;
    if (count.intValue() == 0) return ""; 

    IPrimitiveArray charArray = (IPrimitiveArray) stringObject.resolveValue("value"); 
    if (charArray == null) return null; // return null

    Integer offset = (Integer) stringObject.resolveValue("offset"); 
    if (offset == null) return null; // return null!

    return arrayAsString(charArray, offset, count, limit);
  }

public static String arrayAsString(IPrimitiveArray charArray, int offset, int count, int limit) {
    if (charArray.getType() != IObject.Type.CHAR) return null; // return null

    int length = charArray.getLength();

    int contentToRead = count <= limit ? count : limit;
    if (contentToRead > length - offset) contentToRead = length - offset;

    char[] value;
    if (offset == 0 && length == contentToRead) {
      value = (char[]) charArray.getValueArray();
    } else {
      value = (char[]) charArray.getValueArray(offset, contentToRead);
    }

    if (value == null) return null; // return null

    StringBuilder result = new StringBuilder(value.length);
    for (int ii = 0; ii < value.length; ii++) {
      char val = value[ii];
      if (val >= 32 && val < 127) {
        result.append(val);
      } else {
        result.append("\\u").append(String.format("%04x", 0xFFFF & val)); 
      }
    }
    if (limit < count) result.append("...");
    return result.toString();
  }

  private PrettyPrinter() {
  }

@lawloretienne
Copy link

+1

@akohout
Copy link

akohout commented Nov 17, 2015

+1

@TheIcemanCometh
Copy link

+1

@pyricau Any progress on this ?

@renaudcerrato
Copy link

+1

@Rogero0o
Copy link

+1 Nexus 5 with Marshmallow too, thanks for the software ~

@svareniem
Copy link

+1. Useless for Android 6+. Pls fix it. On Android<6 works perfect. Great job!

@philipgiuliani
Copy link

+1

6 similar comments
@ibamadd
Copy link

ibamadd commented Dec 16, 2015

+1

@gajayraghav
Copy link

+1

@rafaelekol
Copy link

+1

@IgorB10
Copy link

IgorB10 commented Dec 17, 2015

+1

@dudadayan
Copy link

+1

@asos-veskoiliev
Copy link

+1

@halzhang
Copy link

+1 Nexus 6 ,Android 6.0

@baolongnt
Copy link

+1

2 similar comments
@istalev
Copy link

istalev commented Dec 24, 2015

+1

@YuraLaguta
Copy link

+1

@gogeta95
Copy link

+1. Just tried to use this great tool but got stuck.

@Fgabz
Copy link

Fgabz commented Dec 26, 2015

+1

2 similar comments
@toncid
Copy link

toncid commented Dec 28, 2015

+1

@youfacepalm
Copy link

+1

@johngray1965
Copy link

+1 I'd love to use leakcanary, but this is killing me.

@jrodbx
Copy link
Collaborator

jrodbx commented Jan 2, 2016

1.3 issue fixed in 47b098e; 1.4-SNAPSHOT issue fixed in #350

@agbison
Copy link

agbison commented Jan 4, 2016

this is still occurring while testing the snapshot and should not be closed Opened #358 as I don't have permission to reopened closed bugs

@DariusL
Copy link

DariusL commented Feb 20, 2016

I bumped to 1.4-SNAPSHOT and it didn't help. Started working after I uninstalled the application and did a clean build.

@54binge
Copy link

54binge commented Feb 23, 2016

it can't fix it

@pyricau
Copy link
Member

pyricau commented Mar 20, 2016

Please make sure you use 1.4-beta, and if this still happen, create a new issue.

@jrgonzalezg
Copy link

For me, it did not work on the 1.4-beta1, but it started working when i switched to 1.4-SNAPSHOT

@huanjulu
Copy link

same issue
so , any solution here ?
my device is Samsung SM-G930F

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests