RFR: 8339192: Native annotation parsing code of deprecated annotations causes crash

David Holmes dholmes at openjdk.org
Tue Sep 17 04:42:57 UTC 2024


There are a couple of runtime visible annotations (`@Deprecated`, `@Contended`) that the VM processes during classfile parsing. These are expected to have a form that matches the corresponding Java source code in the JDK. The original test cases for this bug fuzzed the annotation entry in the classfile such that the correspondence was lost and so assertions and other errors could be triggered (depending on debug or release builds). The fix is to fully validate the annotation entries that appear to match, and to ignore them otherwise (which is what is required for unknown attributes/annotations).

Each of the jcod test cases is targeted at a specific change in the code (typically the removal of an assertion). There is no intent to try and write exhaustive tests for all possible malformities that might exist for an annotation entry. The original submitted test cases now run without error.

Testing was verified manually by adding debug printing to show we rejected each case as expected. Unfortunately there is no existing mechanism to read back the VM's view of what annotations are present, nor is there any logging to take advantage of. I briefly considered adding a WhiteBox API to query the annotations applied in the VM but I deemed it not worth the effort.

Testing
 - new tests as described above 
 - tier 1-3 sanity

Thanks

-------------

Commit messages:
 - 8339192: Native annotation parsing code of deprecated annotations causes crash

Changes: https://git.openjdk.org/jdk/pull/21030/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21030&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8339192
  Stats: 1136 lines in 9 files changed: 1123 ins; 2 del; 11 mod
  Patch: https://git.openjdk.org/jdk/pull/21030.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21030/head:pull/21030

PR: https://git.openjdk.org/jdk/pull/21030


More information about the hotspot-runtime-dev mailing list