Integrated: JDK-8298908: Instrument Metaspace for ASan

Justin King jcking at openjdk.org
Sat Jan 21 09:06:14 UTC 2023


On Fri, 16 Dec 2022 05:49:53 GMT, Justin King <jcking at openjdk.org> wrote:

> 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.
> 
> This also has the added benefit of making [LSan](https://bugs.openjdk.org/browse/JDK-8298445) more accurate and deterministic, as LSan will not look for pointers to malloc memory in poisoned memory regions.
> 
> IMO the benefit of doing this greatly outweighs the cost.

This pull request has now been integrated.

Changeset: 5331a3ef
Author:    Justin King <jcking at openjdk.org>
Committer: Thomas Stuefe <stuefe at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/5331a3ef739166b2a2b0871fc9615f2c99effa89
Stats:     119 lines in 6 files changed: 109 ins; 5 del; 5 mod

8298908: Instrument Metaspace for ASan

Reviewed-by: stuefe, ihse, iklam

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

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


More information about the hotspot-runtime-dev mailing list