Skip to content
New issue

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

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

Already on GitHub? # to your account

saving project errors, ArrayIndexOutOfBoundsException #2147

Closed
seomarketingads opened this issue Apr 11, 2024 · 2 comments
Closed

saving project errors, ArrayIndexOutOfBoundsException #2147

seomarketingads opened this issue Apr 11, 2024 · 2 comments
Labels
bug Core Issues in jadx-core module regression try-catch

Comments

@seomarketingads
Copy link

Issue details

decompilation is done without errors ( I don't use deobfuscation) but when I try to save all the project to my computer I see ArrayIndexOutOfBoundsException errors in the log view

Relevant log output or stacktrace

ERROR: Method code generation error in method: g0.c.i(int):java.lang.String, file: classes.dex
jadx.core.utils.exceptions.JadxRuntimeException: Unexpected key in switch: class jadx.core.dex.info.FieldInfo
	at jadx.core.codegen.RegionGen.addCaseKey(RegionGen.java:287)
	at jadx.core.codegen.RegionGen.makeSwitch(RegionGen.java:259)
	at jadx.core.dex.regions.SwitchRegion.generate(SwitchRegion.java:84)
	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:62)
	at jadx.core.dex.regions.Region.generate(Region.java:35)
	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:62)
	at jadx.core.dex.regions.Region.generate(Region.java:35)
	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:62)
	at jadx.core.dex.regions.Region.generate(Region.java:35)
	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:62)
	at jadx.core.dex.regions.Region.generate(Region.java:35)
	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:62)
	at jadx.core.dex.regions.Region.generate(Region.java:35)
	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:62)
	at jadx.core.codegen.MethodGen.addRegionInsns(MethodGen.java:297)
	at jadx.core.codegen.MethodGen.addInstructions(MethodGen.java:276)
	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:406)
	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:335)
	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:301)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
	at java.base/java.util.ArrayList.forEach(Unknown Source)
	at java.base/java.util.stream.SortedOps$RefSortingSink.end(Unknown Source)
	at java.base/java.util.stream.Sink$ChainedReference.end(Unknown Source)
	at java.base/java.util.stream.Sink$ChainedReference.end(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
	at jadx.core.codegen.ClassGen.addInnerClsAndMethods(ClassGen.java:297)
	at jadx.core.codegen.ClassGen.addClassBody(ClassGen.java:286)
	at jadx.core.codegen.ClassGen.addClassBody(ClassGen.java:270)
	at jadx.core.codegen.ClassGen.addClassCode(ClassGen.java:161)
	at jadx.core.codegen.ClassGen.makeClass(ClassGen.java:103)
	at jadx.core.codegen.CodeGen.wrapCodeGen(CodeGen.java:45)
	at jadx.core.codegen.CodeGen.generateJavaCode(CodeGen.java:34)
	at jadx.core.codegen.CodeGen.generate(CodeGen.java:22)
	at jadx.core.ProcessClass.process(ProcessClass.java:80)
	at jadx.core.ProcessClass.generateCode(ProcessClass.java:118)
	at jadx.core.dex.nodes.ClassNode.generateClassCode(ClassNode.java:400)
	at jadx.core.dex.nodes.ClassNode.decompile(ClassNode.java:388)
	at jadx.core.dex.nodes.ClassNode.getCode(ClassNode.java:338)
	at jadx.api.JadxDecompiler.lambda$appendSourcesSave$2(JadxDecompiler.java:373)
	at jadx.core.utils.tasks.TaskExecutor.wrapTask(TaskExecutor.java:166)
	at jadx.core.utils.tasks.TaskExecutor.lambda$runStages$0(TaskExecutor.java:147)
	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)
ERROR: ArrayIndexOutOfBoundsException in pass: BlockProcessor in method: n1.v.b(byte[]):f1.c, file: classes.dex
java.lang.ArrayIndexOutOfBoundsException: null
ERROR: ArrayIndexOutOfBoundsException in pass: BlockProcessor in method: n1.v.b(byte[]):f1.c, file: classes.dex
java.lang.ArrayIndexOutOfBoundsException: null

Provide sample and class/method full name

classes.zip

Jadx version

1.4.7.307.dbadbb01

@seomarketingads seomarketingads added bug Core Issues in jadx-core module labels Apr 11, 2024
@skylot
Copy link
Owner

skylot commented Apr 11, 2024

I commit fixes for next issues:

  • FieldInfo in switch case keys was a regression introduces in commits related to [feature] Improve constant replacement by using android sdk libs #2119
  • Turns out for some try/catch jadx can generate CFG with weird loops. I make additional checks to prevent this
  • Actual ArrayIndexOutOfBoundsException was thrown from post dominance tree builder (added in Optimize switch fallthrough #2054) and was caused by loops from previous issue, but for now I am not sure why loops can fail these calculation 😢. As workaround, I restrict running these calcs for only methods with switch block (post-doms used only there).

@seomarketingads
Copy link
Author

thanks mate, with latest nightly version jadx-gui-1.4.7.310-6182332e, no errors are showing up anymore, but thousands of warnings, previously it was only 4 warnings :((

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Core Issues in jadx-core module regression try-catch
Projects
None yet
Development

No branches or pull requests

2 participants