Integrated: 8339192: Native annotation parsing code of deprecated annotations causes crash
David Holmes
dholmes at openjdk.org
Thu Sep 19 23:47:44 UTC 2024
On Tue, 17 Sep 2024 04:37:29 GMT, David Holmes <dholmes at openjdk.org> wrote:
> 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
This pull request has now been integrated.
Changeset: 969c2af9
Author: David Holmes <dholmes at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/969c2af95387992c55a2e1768de848a354e74127
Stats: 1136 lines in 9 files changed: 1123 ins; 2 del; 11 mod
8339192: Native annotation parsing code of deprecated annotations causes crash
Reviewed-by: jrose, mgronlun
-------------
PR: https://git.openjdk.org/jdk/pull/21030
More information about the hotspot-runtime-dev
mailing list