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.ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9 #1796

Closed
FabioNevesRezende opened this issue Mar 9, 2023 · 8 comments
Assignees
Milestone

Comments

@FabioNevesRezende
Copy link

Please describe what you did before the error occurred.
IMPORTANT! If the error occurs with a specific APK file please attach or provide link to apk file!
The error occurred with the apk https://mas.owasp.org/crackmes/Android/#android-uncrackable-l1
When it hit a breakpoint set on the first instruction of the MainAcitivy.verify method

  • Jadx version: 1.4.6
  • Java version: 11.0.18
  • Java VM: Debian OpenJDK 64-Bit Server VM
  • Platform: Linux (5.10.0-21-amd64 amd64)
  • Max heap size: 5508 MB
  • Program args: -Xms128M -XX:MaxRAMPercentage=70.0 -XX:+UseG1GC -Dawt.useSystemAAFontSettings=lcd -Dswing.aatext=true -Djava.util.Arrays.useLegacyMergeSort=true
java.lang.ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9
	at java.desktop/javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1446)
	at java.desktop/javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1389)
	at java.desktop/javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:648)
	at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1680)
	at java.desktop/javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:795)
	at java.desktop/java.awt.Container.layout(Container.java:1537)
	at java.desktop/java.awt.Container.doLayout(Container.java:1526)
	at java.desktop/java.awt.Container.validateTree(Container.java:1722)
	at java.desktop/java.awt.Container.validate(Container.java:1657)
	at java.desktop/javax.swing.RepaintManager$3.run(RepaintManager.java:745)
	at java.desktop/javax.swing.RepaintManager$3.run(RepaintManager.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/javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:742)
	at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1889)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	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.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	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)

@jpstotz
Copy link
Collaborator

jpstotz commented Mar 10, 2023

At a first glance this looks like a bug in Java, not in Jadx. However the exception is very close to this bug report here: https://bugs.openjdk.org/browse/JDK-6253801 And the outcome of this bug report is it was not a Java bug, but a developer problem: UI component were added outside of the main thread.

So may be the the debugger window performs some UI changes on a non-main thread?

@jpstotz
Copy link
Collaborator

jpstotz commented Mar 10, 2023

The PR reference is wrong, I accidentally used the wrong issue number.

@skylot skylot self-assigned this Mar 10, 2023
@skylot skylot added this to the TBD milestone Mar 10, 2023
@skylot skylot added GUI Issues in jadx-gui module debugger bug labels Mar 10, 2023
@FabioNevesRezende
Copy link
Author

Do you guys have any idea of when a version with this bug fix will be released? not to be annoying, the other option for debuggin smali is "smalidea" for Android Studio which is very worse and doesn't work well, this one seems to be the best solution out there and I'm also using jadx-gui for works. Thanks in advance

@jpstotz
Copy link
Collaborator

jpstotz commented Mar 17, 2023

Unfortunately based on the error stack trace it is pretty complicated to identify the code section that is causing this error. Additionally such errors are very hard to reproduce as the execution timing and thus the OS, the used CPU, Java version and whatever have an impact if this error occurs or not. For example I have never seen this error and I can not reproduce it in my set-up.

If you often get this error and you are familiar with IntelliJ you could help us checking out Jadx GIT, open it in IntelliJ and then add an exception break point of ArrayIndexOutOfBoundsException https://www.jetbrains.com/help/idea/using-breakpoints.html#set-breakpoints.

Then Start Jadx-GUI jadx-gui/src/main/java/jadx/gui/JadxGUI.java in debug mode.

If the break-point hits please check the IntelliJ debugger view what list is causing the error (e.g. what are the existing 8 elements and what is this or what UI component does not belong to).

@skylot
Copy link
Owner

skylot commented Mar 17, 2023

@jpstotz you are right, reproduce rate of this issue is very low, and I was unable to trigger it in debug mode 🙁
Anyway, I made changes in several places and now issue not occur for me.
@FabioNevesRezende can you check latest unstable build if issue is resolved for you?

@FabioNevesRezende
Copy link
Author

Well, after changing to Java 17 this error is not happening anymore. However there are some things on the UI that are not very well, for example, the locals values that stands between the callstack and debugger log is not resizable. Also it always show "undefined" for every value of the registers, the main point for me to debug is to check how the variables are changing its values along the execution...

Screenshot_20230401_084258

It always show (JDWP Error Code:35) Invalid slot. for v1...

@jpstotz
Copy link
Collaborator

jpstotz commented Apr 1, 2023

@FabioNevesRezende What device do you use for debugging (real phone - which model, or emulator which emulator type, image architecture and image name)?

@FabioNevesRezende
Copy link
Author

FabioNevesRezende commented Apr 1, 2023

I'm using an image of android-x86 running on Qemu/virt-manager

https://www.android-x86.org/download.html

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

No branches or pull requests

3 participants