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

Disassembler seems to swallow the corrupted part of code without error against corrupted class file #1

Open
HeartSaVioR opened this issue Mar 9, 2020 · 0 comments

Comments

@HeartSaVioR
Copy link

HeartSaVioR commented Mar 9, 2020

Migrated from janino-compiler/janino#113 - the original issue was fixed, but while debugging, disassembler doesn't give any information against corrupted class file hence had to figure out with the field code (byte array) against debugger.

Corrupted class file was generated from Janino (the reason was janino-compiler/janino#113) - I've set breakpoint to UnitCompiler.addClassFile and force debugger to write cf.byteArray() to the file, as well as run Disassembler.disassembleToStdout(cf.toByteArray()).

Archive.zip

It threw error and stopped printing out disassembled code where the bug has been spotted. (tableswitch is in offset 578 in expand_doConsume - got the information while debugging with code field)

Error: A serious internal error has occurred: java.lang.NegativeArraySizeException
Please file a bug report, and include the following information:
java.lang.NegativeArraySizeException
	at com.sun.tools.classfile.Instruction.accept(Instruction.java:288)
	at com.sun.tools.javap.CodeWriter.writeInstr(CodeWriter.java:126)
	at com.sun.tools.javap.CodeWriter.writeInstrs(CodeWriter.java:108)
	at com.sun.tools.javap.CodeWriter.write(CodeWriter.java:75)
	at com.sun.tools.javap.AttributeWriter.visitCode(AttributeWriter.java:220)
	at com.sun.tools.javap.AttributeWriter.visitCode(AttributeWriter.java:75)
	at com.sun.tools.classfile.Code_attribute.accept(Code_attribute.java:102)
	at com.sun.tools.javap.AttributeWriter.write(AttributeWriter.java:101)
	at com.sun.tools.javap.ClassWriter.writeMethod(ClassWriter.java:508)
	at com.sun.tools.javap.ClassWriter.writeMethods(ClassWriter.java:412)
	at com.sun.tools.javap.ClassWriter.write(ClassWriter.java:217)
	at com.sun.tools.javap.JavapTask.write(JavapTask.java:784)
	at com.sun.tools.javap.JavapTask.writeClass(JavapTask.java:606)
	at com.sun.tools.javap.JavapTask.run(JavapTask.java:560)
	at com.sun.tools.javap.JavapTask.run(JavapTask.java:423)
	at com.sun.tools.javap.Main.main(Main.java:46)
  • classfile.class.decompiled-jdisasm-1.x: The output from Disassembler.disassembleToStdout(cf.toByteArray()) (I've done with two versions: 1.4 and 1.5)

  • classfile.class.decompiled-jdisasm-1.5-cli: The output from de.unkrig.jdisasm.Disassembler -verbose

All outputs from jdisasm silently threw out the part (entire code in the method - expand_doConsume) where corrupted operation is placed.

As jdisasm is the recommended way to report the bug on Janino, it would be nice to catch the corrupted code and throw out error (or tolerate the error but log the error message at least).

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

1 participant