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

ArrayIndexOutOfBoundsException when trying to export #206

Open
joshterrill opened this issue Nov 4, 2022 · 7 comments
Open

ArrayIndexOutOfBoundsException when trying to export #206

joshterrill opened this issue Nov 4, 2022 · 7 comments

Comments

@joshterrill
Copy link

joshterrill commented Nov 4, 2022

I've started ClassyShark using the command referenced in the README file, and in the left-hand tree, I'll click on a folder or file, then click the export button, and I get this error:

java.lang.ArrayIndexOutOfBoundsException: 6392800
	at org.ow2.asmdex.lowLevelUtils.DexFileReader.getStringItemFromStringIndex(DexFileReader.java:104)
	at org.ow2.asmdex.ApplicationReader.readAnnotationElement(ApplicationReader.java:1493)
	at org.ow2.asmdex.ApplicationReader.readEncodedAnnotation(ApplicationReader.java:1518)
	at org.ow2.asmdex.ApplicationReader.readEncodedValue(ApplicationReader.java:861)
	at org.ow2.asmdex.ApplicationReader.readAnnotationElement(ApplicationReader.java:1494)
	at org.ow2.asmdex.ApplicationReader.parseSpecificAnnotations(ApplicationReader.java:1473)
	at org.ow2.asmdex.ApplicationReader.readDefaultAnnotations(ApplicationReader.java:1271)
	at org.ow2.asmdex.ApplicationReader.visitClass(ApplicationReader.java:561)
	at org.ow2.asmdex.ApplicationReader.accept(ApplicationReader.java:437)
	at org.ow2.asmdex.ApplicationReader.accept(ApplicationReader.java:338)
	at com.google.classyshark.silverghost.translator.dex.DexMethodsDumper.fillAnalysis(DexMethodsDumper.java:106)
	at com.google.classyshark.silverghost.translator.dex.DexMethodsDumper.dumpMethods(DexMethodsDumper.java:84)
	at com.google.classyshark.silverghost.exporter.Exporter.writeMethods(Exporter.java:89)
	at com.google.classyshark.silverghost.exporter.Exporter.writeArchive(Exporter.java:47)
	at com.google.classyshark.gui.panel.ClassySharkPanel$3.doInBackground(ClassySharkPanel.java:207)
	at com.google.classyshark.gui.panel.ClassySharkPanel$3.doInBackground(ClassySharkPanel.java:202)
	at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at javax.swing.SwingWorker.run(SwingWorker.java:334)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Based on the stacktrace, it looks like the error is occurring somewhere around here:

@yijigu7745
Copy link

yijigu7745 commented Nov 4, 2022 via email

@borisf
Copy link
Collaborator

borisf commented Nov 5, 2022

It seems an issue with one of the ClassyShark dependencies, ASMDex, not sure something we can help with

@joshterrill
Copy link
Author

@borisf did this work with a previous version of ASMDex? Is this just a specific edge case with the class that I'm looking at? I found this reference on their Gitlab which could be related: https://gitlab.ow2.org/asm/asm/-/issues/317957

I also saw in this issue: #204 that there was maybe a plan to remove the local ASMDex dependency and references all together? Is this still the plan? Is there a replacement that exists out there?

@borisf
Copy link
Collaborator

borisf commented Nov 7, 2022

Did this work with a previous version of ASMDex? - I don't think we changed any asmdex dependencies.

Is this just a specific edge case with the class that I'm looking at? I found this reference on their Gitlab which could be related: https://gitlab.ow2.org/asm/asm/-/issues/317957 - I am not sure this is related, as the link shows ASM, which is class format library, while asmdex is a dex format library.

I also saw in this issue: #204 that there was maybe a plan to remove the local ASMDex dependency and references all together? Is this still the plan? Is there a replacement that exists out there? - unfortunately, I can't alocate much time to this project now, but pull requests are welcome.

@joshterrill
Copy link
Author

@borisf I could look at submitting a PR. If ASMDex should be replaced, do you have a preference with what should replace it? If not, I can just do some testing and see what's out there and available. Unfortunately, it looks like the asmdex repo has not been contributed to in a while.

@borisf
Copy link
Collaborator

borisf commented Nov 7, 2022

I think it is the best to remove the ASMDex all together. We have dexlib2 that parses classes.dex entries. AMSDex used in the following classes:

https://github.com/google/android-classyshark/blob/master/ClassySharkWS/src/com/google/classyshark/silverghost/translator/dex/DexMethodsDumper.java ==> dumps all methods to a file, can happily use other alternatives

https://github.com/google/android-classyshark/blob/master/ClassySharkWS/src/com/google/classyshark/silverghost/translator/apk/dashboard/ApkDashboard.java ==> calls ApkNativeMethodsVisitor.java, the next class

https://github.com/google/android-classyshark/blob/master/ClassySharkWS/src/com/google/classyshark/silverghost/translator/apk/dashboard/ApkNativeMethodsVisitor.java ==> for native methods stats (not sure we need them)

@joshterrill
Copy link
Author

Awesome, thanks for your input @borisf. I'll fork the repo and look at it some time this week and then submit a PR if I can figure out a good fix.

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