AdoptOpenJDK / jitwatch

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.
Other
3.06k stars 437 forks source link

could not parse bytecode: '}' #319

Closed Mythra closed 4 years ago

Mythra commented 4 years ago

Hey,

First off thank you so much for this! I'm trying to analyze an example 1.8 kotlin codebase of mine, to get used to running the tool. When running the jarScan on a shadow jar I've compiled I'm running into a unique error:

$ ./jarScan.sh --mode=maxMethodSize --limit=325 --packages="dev.cynthia.*" ../../build/libs/project-0.1.0-SNAPSHOT-all.jar
14:26:02.641 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:02.670 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:02.804 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:02.844 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:02.869 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.081 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.094 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.187 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.198 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.204 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.226 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.243 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.261 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
14:26:03.405 [main] ERROR o.a.jitwatch.loader.BytecodeLoader - could not parse bytecode: '}'
[...]

The tool still prints out a CSV report, but I'm worried that it's not fully analyzing some classes due to this "could not parse bytecode", in fact I'm not sure which files are reporting them either. I'd be happy to give more logs, but I'm not quite sure what would be most helpful. So if you need anything from me just let me know.

chriswhocodes commented 4 years ago

Hi @SecurityInsanity Any chance you can share the jar file you are trying to analyse? Thanks, Chris

Mythra commented 4 years ago

Hey Chris,

Sure do you have an email or something I can send it to? I'd prefer to not share it publicly fully yet. If not, I can try to build a reproducible sample case that I don't mind sharing.

chriswhocodes commented 4 years ago

chris@chrisnewland.com please. Thanks

Mythra commented 4 years ago

Email Sent. Thanks!

chriswhocodes commented 4 years ago

Thanks for the email. I think you've found a bug in JITWatch's bytecode parser.

Most of the failures are related to static inner class initialisers (clinit). I'll try and create a regression test and then fix.

Thanks for reporting!

chriswhocodes commented 4 years ago

Fixed by https://github.com/AdoptOpenJDK/jitwatch/commit/4cf90e22d4e2c5f65d67eda8c848cfd1483eccd7

This was caused by a bug in the parser which didn't handle the case that a Code: section could be followed directly by the closing } without any line number table, exception table etc.

Thanks again for reporting @SecurityInsanity !