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

Smalidea watchers "Internal error" #691

Closed
kevanlanister735 opened this issue Apr 3, 2019 · 15 comments · Fixed by JesusFreke/smalidea#10
Closed

Smalidea watchers "Internal error" #691

kevanlanister735 opened this issue Apr 3, 2019 · 15 comments · Fixed by JesusFreke/smalidea#10
Labels

Comments

@kevanlanister735
Copy link

Hello,

I am using IntelliJ IDEA 2019.1 and the smalidea plugin 0.05 to debug an application. It seems like the step debugging is working fine, but no matter which functions I am in, the v0,v1 and p0,p1 etc locals and parameters are showing as "Internal error" when I add them to watchers.

I am using java8_151 jdk.

Any ideas?

@pwnpanda
Copy link

pwnpanda commented Apr 15, 2019

Same problem, but on Android Studios.

Stack trace:
com.sun.jdi.InternalException: Unexpected JDWP Error: 35 at com.sun.tools.jdi.JDWPException.toJDIException(JDWPException.java:65) at com.sun.tools.jdi.StackFrameImpl.getValues(StackFrameImpl.java:241) at com.sun.tools.jdi.StackFrameImpl.getValue(StackFrameImpl.java:201) at org.jf.smalidea.debugging.SmaliCodeFragmentFactory.evaluateRegister(SmaliCodeFragmentFactory.java:331) at org.jf.smalidea.debugging.value.LazyValue.getNullableValue(LazyValue.java:119) at org.jf.smalidea.debugging.value.LazyValue.getValue(LazyValue.java:133) at org.jf.smalidea.debugging.value.LazyValue.type(LazyValue.java:140) at com.intellij.debugger.ui.tree.ValueDescriptor.getType(ValueDescriptor.java:37) at com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl.getRenderer(ValueDescriptorImpl.java:421) at com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl.calcRepresentation(ValueDescriptorImpl.java:288) at com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl.updateRepresentationNoNotify(NodeDescriptorImpl.java:69) at com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl.updateRepresentation(NodeDescriptorImpl.java:61) at com.intellij.debugger.engine.JavaValue$1.contextAction(JavaValue.java:153) at com.intellij.debugger.engine.events.SuspendContextCommandImpl.action(SuspendContextCommandImpl.java:57) at com.intellij.debugger.engine.events.DebuggerCommandImpl.run(DebuggerCommandImpl.java:33) at com.intellij.debugger.engine.DebuggerManagerThreadImpl.processEvent(DebuggerManagerThreadImpl.java:133) at com.intellij.debugger.engine.DebuggerManagerThreadImpl.processEvent(DebuggerManagerThreadImpl.java:29) at com.intellij.debugger.impl.InvokeThread.run(InvokeThread.java:138) at com.intellij.debugger.impl.InvokeThread.access$100(InvokeThread.java:19) at com.intellij.debugger.impl.InvokeThread$WorkerThreadRequest.lambda$run$0(InvokeThread.java:49) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:229) at com.intellij.debugger.impl.InvokeThread$WorkerThreadRequest.run(InvokeThread.java:48) at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

@lekanteto
Copy link

same problem as #651 ?

@st4ycool
Copy link

Same problem trying to see what p0 contains. Sometimes it's NPE in log and debugger fails, sometimes it's just internal error and debugger fails =(

@josefst
Copy link

josefst commented Sep 4, 2019

Same problem using IntelliJ IDEA 2019.2

@wrobezin
Copy link

Same problem using Android Studios 3.5.2

@n3tman
Copy link

n3tman commented Jan 30, 2020

Android Studio 3.5.3 with smalidea-0.05:

2020-01-30_162904

Variables v1 and v2 have been set, but Watcher shows an Internal error.
In most cases it works fine, but here it doesn't.

Stack trace:

java.lang.NullPointerException
	at org.jf.dexlib2.analysis.MethodAnalyzer.addPredecessorSuccessor(MethodAnalyzer.java:567)
	at org.jf.dexlib2.analysis.MethodAnalyzer.addPredecessorSuccessor(MethodAnalyzer.java:587)
	at org.jf.dexlib2.analysis.MethodAnalyzer.addPredecessorSuccessor(MethodAnalyzer.java:552)
	at org.jf.dexlib2.analysis.MethodAnalyzer.buildInstructionList(MethodAnalyzer.java:514)
	at org.jf.dexlib2.analysis.MethodAnalyzer.<init>(MethodAnalyzer.java:127)
	at org.jf.smalidea.psi.impl.SmaliMethod.getMethodAnalyzer(SmaliMethod.java:327)
	at org.jf.smalidea.psi.impl.SmaliInstruction.getAnalyzedInstructionFromMethod(SmaliInstruction.java:199)
	at org.jf.smalidea.psi.impl.SmaliInstruction.getAnalyzedInstruction(SmaliInstruction.java:222)
	at org.jf.smalidea.debugging.SmaliCodeFragmentFactory.wrapContext(SmaliCodeFragmentFactory.java:138)
	at org.jf.smalidea.debugging.SmaliCodeFragmentFactory.createPresentationCodeFragment(SmaliCodeFragmentFactory.java:94)
	at com.intellij.debugger.engine.evaluation.CodeFragmentFactoryContextWrapper.createPresentationCodeFragment(CodeFragmentFactoryContextWrapper.java:49)
	at org.jetbrains.java.debugger.JavaDebuggerEditorsProvider.createExpressionCodeFragment(JavaDebuggerEditorsProvider.java:77)
	at com.intellij.xdebugger.evaluation.XDebuggerEditorsProviderBase.createDocument(XDebuggerEditorsProviderBase.java:67)
	at com.intellij.xdebugger.evaluation.XDebuggerEditorsProviderBase.createDocument(XDebuggerEditorsProviderBase.java:59)
	at com.intellij.xdebugger.impl.ui.XDebuggerEditorBase.createDocument(XDebuggerEditorBase.java:347)
	at com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox.createDocument(XDebuggerExpressionComboBox.java:130)
	at com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox.doSetText(XDebuggerExpressionComboBox.java:119)
	at com.intellij.xdebugger.impl.ui.XDebuggerEditorBase.setExpression(XDebuggerEditorBase.java:279)
	at com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox.<init>(XDebuggerExpressionComboBox.java:59)
	at com.intellij.xdebugger.impl.ui.tree.XDebuggerTreeInplaceEditor.<init>(XDebuggerTreeInplaceEditor.java:47)
	at com.intellij.xdebugger.impl.frame.WatchInplaceEditor.<init>(WatchInplaceEditor.java:42)
	at com.intellij.xdebugger.impl.ui.tree.nodes.WatchesRootNode.editWatch(WatchesRootNode.java:186)
	at com.intellij.xdebugger.impl.frame.actions.XEditWatchAction.perform(XEditWatchAction.java:46)
	at com.intellij.xdebugger.impl.frame.actions.XWatchesTreeActionBase.actionPerformed(XWatchesTreeActionBase.java:62)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:261)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:278)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:625)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$processAction$2(IdeKeyEventDispatcher.java:674)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:673)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:518)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:473)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:223)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:681)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:375)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

@JesusFreke
Copy link
Owner

n3tman, can you share the full method that was causing the NPE you mentioned? It looks like the class is from androidx.appcompat.app, so it shouldn't be sensitive.

@n3tman
Copy link

n3tman commented Feb 5, 2020

Sure, but it's not the original code. I was analysing some changes made by other people.
The purpuse, as I found out, is to check if .apk signature matches a constant value.
If it doesn't, the app is closed.

Method L from the screenshot above:

.method public static l(Ljava/lang/String;)Ljava/lang/String;
    .locals 11
    const-string v1, ""
    :try_start_0
    new-instance v0, Ljava/lang/String;
    const/4 v2, 0x0
    invoke-static {p0, v2}, Landroid/util/Base64;->decode(Ljava/lang/String;I)[B
    move-result-object v2
    const-string v3, "UTF-8"
    invoke-direct {v0, v2, v3}, Ljava/lang/String;-><init>([BLjava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
    :goto_0
    return-object v0
    :catch_0
    move-exception v0
    move-object v0, v1
    goto :goto_0
.end method

Which is called by another custom method loadApplication

.method public loadApplication()V
    .locals 2
    invoke-virtual {p0}, Landroidx/appcompat/app/e;->getClass()Ljava/lang/Class;
    move-result-object v0
    invoke-virtual {v0}, Ljava/lang/Class;->getClassLoader()Ljava/lang/ClassLoader;
    move-result-object v0
    const-string v1, "26U="
    invoke-static/range {v1 .. v1}, Landroidx/appcompat/app/e;->l(Ljava/lang/String;)Ljava/lang/String;
    move-result-object v1
    invoke-virtual {v0, v1}, Ljava/lang/ClassLoader;->getResourceAsStream(Ljava/lang/String;)Ljava/io/InputStream;
    move-result-object v0
    if-nez v0, :cond_0
    const/4 v0, 0x0
    invoke-static {v0}, Ljava/lang/System;->exit(I)V
    :cond_0
    return-void
.end method

And this method is called inside onStart

.method protected onCreate(Landroid/os/Bundle;)V
    .locals 1
    invoke-virtual {p0}, Landroidx/appcompat/app/e;->getDelegate()Landroidx/appcompat/app/g;
    move-result-object v0
    invoke-virtual {v0}, Landroidx/appcompat/app/g;->e()V
    invoke-virtual {v0, p1}, Landroidx/appcompat/app/g;->a(Landroid/os/Bundle;)V
    invoke-virtual {p0}, Landroidx/appcompat/app/e;->loadApplication()V
    invoke-super {p0, p1}, Landroidx/fragment/app/d;->onCreate(Landroid/os/Bundle;)V
    return-void
.end method

@JesusFreke
Copy link
Owner

Thanks, I'll take a look and see if I can reproduce the NPE. I couldn't find anything just by looking at the code, unfortunately.

@JesusFreke
Copy link
Owner

I can't seem to reproduce the NPE unfortunately. I'm able to make a MethodAnalyzer for all 3 of those methods with no problem.

@ttimasdf
Copy link

ttimasdf commented Mar 9, 2020

I don't remember exactly but I recall there's (maybe) a change in JDWP implementation on Android somewhere between Nouget and Pie, that preventing JDWP client from retrieving local variable information.


Edit:
Oh I found the original post, as mentioned by #737 (comment)
https://www.pnfsoftware.com/blog/debugging-android-apps-on-android-pie-and-above/

@zc2tech
Copy link

zc2tech commented May 24, 2020

Same issue, any resolutions ?

@jackwpa
Copy link

jackwpa commented May 24, 2020

It's been explained on the blog post linked above, from the JEB Decompiler website. Use Android R or anything less or equal than Android O.
Both Android P and Q suffer that issue.

@GammaRay360
Copy link

It's been explained on the blog post linked above, from the JEB Decompiler website. Use Android R or anything less or equal than Android O.
Both Android P and Q suffer that issue.

I have the same issue with android 6.0.1 nexus 5. Debugging with android studio.
Also sometimes, especially with variables p0, p1, p2, the debugger crash when i inspect their value. sometimes the whole process crash and I need to restart the app to debug again.
The "this" reference always works tough
Screen Shot 2020-05-25 at 12 48 35

@n3tman
Copy link

n3tman commented Jul 15, 2020

Yeah, I as well noticed that you can restart Android Studio to make some Internal Errors go away.
So whenever I need to explore the registers, I just put one breakpoint, restart the Studio, and it stops and shows them all.
However, after some time you might see these errors again.
Also, it's normal that in some areas of the code you won't be able to stop the execution. The debugger just disconnects itself.
In this case just find some other function (before or after) where you can put a breakpoint. Or use good old logcat debug (print register values there).

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

Successfully merging a pull request may close this issue.