RFR: JDK-8298908: Instrument Metaspace for ASan
Justin King
jcking at openjdk.org
Fri Dec 16 06:00:12 UTC 2022
This change instruments Metaspace for ASan. Metaspace allocates memory using `mmap`/`munmap` which ASan is not aware of. Fortunately ASan supports applications [manually poisoning/unpoisoning memory](https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning). ASan is able to detect poisoned memory, similar to `use-after-free`, and will raise an error similarly called `use-after-poison`. This provides and extra layer of defense and confidence.
The header `sanitizers/address.h` defines macros for poisoning/unpoisoning memory regions. These macros can be used regardless of build mode. When ASan is not available, they are implemented using a NOOP approach which still compiles the arguments but does so such that they will be stripped out by the compiler due to being unreachable. This helps with maintenance.
IMO the benefit of doing this greatly outweighs the cost.
-------------
Commit messages:
- Instrument Metaspace for ASan
Changes: https://git.openjdk.org/jdk/pull/11702/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11702&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8298908
Stats: 143 lines in 7 files changed: 122 ins; 1 del; 20 mod
Patch: https://git.openjdk.org/jdk/pull/11702.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/11702/head:pull/11702
PR: https://git.openjdk.org/jdk/pull/11702
More information about the hotspot-runtime-dev
mailing list