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

David Holmes dholmes at openjdk.org
Tue Sep 17 05:36:58 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, particularly because it didn't really help validate the tests in many cases. For example, by default no class/method/field is "Deprecated for Removal" so a test that skips `forRemoval` setting just leaves you with the default situation. You can't actually tell a bad annotation was skipped.
> 
> Testing
>  - new tests as described above 
>  - tier 1-3 sanity
> 
> Thanks

David Holmes has updated the pull request incrementally with one additional commit since the last revision:

  MIN macro was Linux specific - need MIN2

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/21030/files
  - new: https://git.openjdk.org/jdk/pull/21030/files/c71a7730..1e7f7b00

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=21030&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21030&range=00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 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