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 0 out of bounds for length 0' When performing instrumentation by soot. #2093

Open
AlphaDora opened this issue Aug 26, 2024 · 4 comments

Comments

@AlphaDora
Copy link

Please examine each of the following points so that we can help you as soon and best as possible.

Describe the bug
After instrumenting HBase(2.4.2) and generating .class files, I met this issues:
[Thread-44] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: Index 0 out of bounds for length 0
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at org.objectweb.asm.MethodWriter.visitParameterAnnotation(MethodWriter.java:703)
at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:347)
at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:277)
at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:226)
at soot.PackManager.writeClass(PackManager.java:1124)
at soot.PackManager.lambda$writeOutput$1(PackManager.java:705)
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:834)

Input file
I utilized soot-4.3.0 and download Hbase hbase-2.4.2-bin.tar.gz. My source code is too large to upload. If necessary, I will upload my analyzer to support reproducing.

To reproduce
Steps to reproduce the behavior:
Run my scripts.

Expected behavior
According to the log info, the instrumentation process finished and the error occurred during generating .class files.

@AlphaDora
Copy link
Author

Hi @Mlecherf , do you mean I can upload my source code via Mediafire?

@StevenArzt
Copy link
Contributor

Can you provide a minimum working example? If you have a large analyzer, we don't have the time to debug into that. Please provide a small program thta is just enough to reproduce the problem.

@AlphaDora
Copy link
Author

Hi@StevenArzt , sorry for my late reply. I didn't encounter this issue again, but I encountered another strange issue now.
After I used soot to instrument hbase, the exported binary file was slightly different from the source file, which caused an error.
The original binary code in MasterRpcServices.class is as follows:

15: invokestatic #161 // InterfaceMethod org/apache/hadoop/hbase/master/LoadBalancer.isMasterCanHostUserRegions:(Lorg/apache/hadoop/conf/Configuration;)Z

After soot regeneration, this line of bytecode becomes:

16: invokestatic #1920 // Method org/apache/hadoop/hbase/master/LoadBalancer.isMasterCanHostUserRegions:(Lorg/apache/hadoop/conf/Configuration;)Z

When I start hbase master, an error will be reported:
java.lang.IncompatibleClassChangeError: Method org.apache.hadoop.hbase.master.LoadBalancer.isMasterCanHostUserRegions(Lorg/apache/hadoop/conf/Configuration;)Z must be InterfaceMethodref constant
at org.apache.hadoop.hbase.master.MasterRpcServices.createRpcServer(MasterRpcServices.java)

That is, this method should be an InterfaceMethod instead of a Method
I'm currently using soot-4.3.0 and my soot options are as followed:
// General Options
"-w",

                // Input Options
                "-cp", classPath,
                "-pp",
                "-allow-phantom-refs",
                "-no-bodies-for-excluded",

                // Output Options
                "-f", "c",

                // Phase Options
                "-p", "cg", "off"

I'm not explicitly calling asm to modify the binary, so is this because I've turned on some optimization switch incorrectly? How can I fix this error?
If you need me to upload my analyzer, please let me know. Thank you very much for your help.

@AlphaDora
Copy link
Author

Here are the class files before and after analysis.
MasterRpcServices.zip

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
@StevenArzt @AlphaDora and others