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

Failed to init debugger #1412

Closed
RebootSTR opened this issue Mar 18, 2022 · 6 comments
Closed

Failed to init debugger #1412

RebootSTR opened this issue Mar 18, 2022 · 6 comments
Assignees
Labels
bug debugger GUI Issues in jadx-gui module
Milestone

Comments

@RebootSTR
Copy link

RebootSTR commented Mar 18, 2022

I cant debug any app. Try with modified MiFit 5.2.2 (android:debuggable="true" setted) and my person app (debug from AndroudStudio worked).
Preferences in Setting for developer as FAQ
OS: MIUI 12.0.2
Android: 10
Root: yes

Log from jadx:

ERROR: Failed to attach to process
java.lang.NullPointerException: Cannot invoke "java.util.Map.entrySet()" because "jadx.gui.device.debugger.BreakpointManager.bpm" is null
	at jadx.gui.device.debugger.BreakpointManager.getAllBreakpoints(BreakpointManager.java:198)
	at jadx.gui.device.debugger.DebugController.startDebugger(DebugController.java:105)
	at jadx.gui.ui.panel.JDebuggerPanel.showDebugger(JDebuggerPanel.java:377)
	at jadx.gui.ui.dialog.ADBDialog.attachProcess(ADBDialog.java:358)
	at jadx.gui.ui.dialog.ADBDialog.processSelected(ADBDialog.java:339)
	at jadx.gui.ui.dialog.ADBDialog.access$100(ADBDialog.java:54)
	at jadx.gui.ui.dialog.ADBDialog$1.mouseClicked(ADBDialog.java:133)
	at java.desktop/java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
ERROR: Error in debugger decoding loop
jadx.gui.device.debugger.SmaliDebugger$SmaliDebuggerException: read packet failed.
	at jadx.gui.device.debugger.SmaliDebugger.readPacket(SmaliDebugger.java:1153)
	at jadx.gui.device.debugger.SmaliDebugger.lambda$decodingLoop$7(SmaliDebugger.java:680)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
@RebootSTR RebootSTR added bug Core Issues in jadx-core module labels Mar 18, 2022
@skylot
Copy link
Owner

skylot commented Mar 18, 2022

@RebootSTR thanks for report!
Main issue here is: read packet failed - looks like jadx failed to parse binary JDWP packet.
I can reproduce this issue, but still not sure how to fix this (binary protocols are much harder to debug 😢 )

@skylot skylot added this to the TBD milestone Mar 18, 2022
@skylot skylot added GUI Issues in jadx-gui module debugger and removed Core Issues in jadx-core module labels Mar 18, 2022
@jpstotz
Copy link
Collaborator

jpstotz commented Mar 18, 2022

@skylot I think in this case it may be easy, because there is only one way to get this exception: The following if clause fails:

if (inputStream.read(bytes, 0, bytes.length) == bytes.length) {

which is not really surprising because read can but does not have to return the number of requested bytes. This is a very common mistake on Java developers. The standard solution would be to use a DataInputStream and readFully instead.

@skylot
Copy link
Owner

skylot commented Mar 19, 2022

I commit a fix to handle partial reads and correct stop on stream end on debug end/restart (as @jpstotz suggested).
@RebootSTR not sure if this will help, but please check latest unstable build, at least it should reduce errors count in log 🙂

@RebootSTR
Copy link
Author

@skylot i have another errors in log

ERROR: Debug error
jadx.gui.device.debugger.SmaliDebugger$SmaliDebuggerException: jdwp handshake failed
	at jadx.gui.device.debugger.SmaliDebugger.handShake(SmaliDebugger.java:642)
	at jadx.gui.device.debugger.SmaliDebugger.initJDWP(SmaliDebugger.java:615)
	at jadx.gui.device.debugger.SmaliDebugger.attach(SmaliDebugger.java:143)
	at jadx.gui.device.debugger.DebugController.startDebugger(DebugController.java:86)
	at jadx.gui.ui.panel.JDebuggerPanel.showDebugger(JDebuggerPanel.java:377)
	at jadx.gui.ui.dialog.ADBDialog.attachProcess(ADBDialog.java:358)
	at jadx.gui.ui.dialog.ADBDialog.processSelected(ADBDialog.java:339)
	at jadx.gui.ui.dialog.ADBDialog.access$100(ADBDialog.java:54)
	at jadx.gui.ui.dialog.ADBDialog$1.mouseClicked(ADBDialog.java:133)
	at java.desktop/java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:278)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6638)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
	at java.desktop/java.awt.Component.processEvent(Component.java:6400)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4556)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.base/java.net.SocketInputStream.socketRead0(Native Method)
	at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
	at java.base/java.net.SocketInputStream.read(SocketInputStream.java:126)
	at jadx.gui.device.debugger.SmaliDebugger.handShake(SmaliDebugger.java:640)
	... 39 common frames omitted

@jpstotz
Copy link
Collaborator

jpstotz commented Mar 19, 2022

@RebootSTR That error is not Jadx fault. It simply means that the on-device debugger does not answer the handshake. This also happens on all of my devices. Seems like the recent adb version has some bugs, because Android Studio also fails to connect it's debugger to any app process to be debugged.
If you have updated adb recently try to go back to the old version.

I noticed that the handshake process also uses read the same wrong way as in readPacket but that is not causing the "Read timed out" problem.

@RebootSTR
Copy link
Author

@jpstotz You right! Another version adb worked for me. Thank you and @skylot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug debugger GUI Issues in jadx-gui module
Projects
None yet
Development

No branches or pull requests

3 participants