isstac / kelinci

AFL-based fuzzing for Java
Apache License 2.0
231 stars 53 forks source link

Illegal Access Error #16

Open amitrege opened 5 years ago

amitrege commented 5 years ago

Hi, When I run java -cp ./instrumentor/build/libs/kelinci.jar edu.cmu.sv.kelinci.instrumentor.Instrumentor -i ../bin -o ../bin-instrumented I get the following error

Loading dir: ../bin Found file ../bin/sorting_algo/sorting.class Found file ../bin/Driver.class WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by edu.cmu.sv.kelinci.instrumentor.Options (file:/home/amit/dev-work/Cost_Model_NN/new_fuzzing/kelinci/instrumentor/build/libs/kelinci.jar) to method java.net.URLClassLoader.addURL(java.net.URL) WARNING: Please consider reporting this to the maintainers of edu.cmu.sv.kelinci.instrumentor.Options WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Exception in thread "main" java.lang.RuntimeException: Error adding location to class path: ../bin at edu.cmu.sv.kelinci.instrumentor.Options.addToClassPath(Options.java:62) at edu.cmu.sv.kelinci.instrumentor.Options.getInput(Options.java:46) at edu.cmu.sv.kelinci.instrumentor.Instrumentor.main(Instrumentor.java:43)

I have tried changing my JDK from 11 to 8 but I still get the same error. Any ideas on how to fix this?

Thanks

escube commented 4 years ago

Same thing here, did you manage to fix it?

After trying to see what is the source of the problem, seems to be line 60, the invoke_method fails. Adding a printstacktrace to the catch exception, gives me the following stacktrace :

java.lang.IllegalArgumentException: object is not an instance of declaring class at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at edu.cmu.sv.kelinci.instrumentor.Options.addToClassPath(Options.java:59) at edu.cmu.sv.kelinci.instrumentor.Options.getInput(Options.java:45) at edu.cmu.sv.kelinci.instrumentor.Instrumentor.main(Instrumentor.java:43)

escube commented 4 years ago

I solved the problem in this way : 1) Removed all library from -cp command and left only kelenci. At this point I had another exception that is : java.lang.IllegalArgumentException at org.objectweb.asm.ClassReader.(Unknown Source) at org.objectweb.asm.ClassReader.(Unknown Source) at org.objectweb.asm.ClassReader.(Unknown Source) at edu.cmu.sv.kelinci.instrumentor.Instrumentor.main(Instrumentor.java:55)

The excpetion was not very clear, so I updated org.ow2.asm from version 5.2 to version 7.2.

It is compiling fine now.

krisohotski commented 4 years ago

adding "--illegal-permit access" at the end of the cmd seems to fix this issue.

shijy16 commented 4 years ago

I fixed the bug by using java8 instead of other versions.

YJDave commented 4 years ago

I was getting same error, changing to java8 version worked. Thank you @shijy16

WayneDevMaze commented 1 year ago

change to java8, worked!!!

  1. install 安装 sudo apt-get install openjdk-8-jdk

  2. change version 变化Java版本 sudo update-java-alternatives -s java-8-oracle 图片 注:变更版本可以在这里查看 ls /usr/lib/jvm/java-8-oracle

  3. 重新执行,执行一定要sudo