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

java.lang.NullPointerException #1575

Closed
Luffitys opened this issue Jul 11, 2022 · 3 comments
Closed

java.lang.NullPointerException #1575

Luffitys opened this issue Jul 11, 2022 · 3 comments

Comments

@Luffitys
Copy link

Luffitys commented Jul 11, 2022

Please describe what you did before the error occurred.
Trying to debug the app, during the launch jadx had this issue.
IMPORTANT! If the error occurs with a specific APK file please attach or provide link to apk file!
https://www.celsoazevedo.com/files/android/google-camera/dev-bsg/f/dl92/

  • Jadx version: 1.4.2.35-51555667
  • Java version: 11.0.15
  • Java VM: Eclipse Adoptium OpenJDK 64-Bit Server VM
  • Platform: Windows 11 (10.0 amd64)
  • Max heap size: 6526 MB
  • Program args: -Xms466m -Xmx6525m -Dawt.useSystemAAFontSettings=lcd -Dswing.aatext=true -XX:+UseG1GC
java.lang.NullPointerException
	at jadx.gui.device.debugger.smali.Smali.fmtSwitchPayload(Smali.java:766)
	at jadx.gui.device.debugger.smali.Smali.fmtPayloadInsn(Smali.java:736)
	at jadx.gui.device.debugger.smali.Smali.formatInsn(Smali.java:344)
	at jadx.gui.device.debugger.smali.Smali.decodeInsn(Smali.java:336)
	at jadx.gui.device.debugger.smali.Smali.lambda$writeMethod$2(Smali.java:292)
	at jadx.plugins.input.dex.sections.DexCodeReader.visitInstructions(DexCodeReader.java:85)
	at jadx.gui.device.debugger.smali.Smali.writeMethod(Smali.java:291)
	at jadx.gui.device.debugger.smali.Smali.lambda$writeClass$1(Smali.java:219)
	at jadx.plugins.input.dex.sections.DexClassData.readMethods(DexClassData.java:170)
	at jadx.plugins.input.dex.sections.DexClassData.visitMethods(DexClassData.java:145)
	at jadx.plugins.input.dex.sections.DexClassData.visitFieldsAndMethods(DexClassData.java:112)
	at jadx.gui.device.debugger.smali.Smali.writeClass(Smali.java:203)
	at jadx.gui.device.debugger.smali.Smali.disassemble(Smali.java:86)
	at jadx.gui.device.debugger.DbgUtils.lambda$getSmali$0(DbgUtils.java:32)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
	at jadx.gui.device.debugger.DbgUtils.getSmali(DbgUtils.java:31)
	at jadx.gui.device.debugger.DebugController.openMainActivityTab(DebugController.java:109)
	at jadx.gui.device.debugger.DebugController.lambda$stopAtOnCreate$0(DebugController.java:121)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

@jpstotz
Copy link
Collaborator

jpstotz commented Jul 12, 2022

Thanks for reporting.

The problematic code line that throws NullPointerException is:

int opcodeOffset = line.payloadOffsetMap.get(curOffset);

line and payloadOffsetMap seem to be always not null, so the exception should be caused by a conversion from Integer to int of a null value (the map has no entry for curOffset).

@Luffitys Can you please tell use which of the linked APK files you were viewing (and which class) when the error occurred?

@Luffitys
Copy link
Author

@jpstotz All the APKs are fundamentally the same, but with a different package name. In this case, I used “MGC_8.4.600_A10_V13_snap.apk”.
In my settings, I have auto decompilation turned on, so the APK was already decompiled. I attached the debugger to my phone and started launched the app, without opening any classes.

@skylot
Copy link
Owner

skylot commented Jul 18, 2022

Fixed.
Issue was in code generator for debug smali, it expects switch payload after switch instruction, but this is not correct and order can be reversed. I add another instructions pass to collect this data before actual code generation.

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

3 participants