RFR: JDK-8327971: Multiple ASAN errors reported for metaspace
Guoxiong Li
gli at openjdk.org
Wed Mar 13 02:42:12 UTC 2024
On Tue, 12 Mar 2024 11:45:47 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> When adding ASAN support for metaspace, we decided to track poisoning not at the OS border (map) but at the border between metaspace and outer JVM code (or, more precisely, at the border of ChunkManager chunk allocation/deallocation).
>
> Chunks handed out by the chunk manager are unpoisoned, poisoned when handed back.
>
> This causes some problems, since within metaspace we access memory that is committed but not yet handed to the user. So from the ASANs view, that memory is poisoned; from the view of the metaspace allocator, these accesses are perfectly valid.
>
> Basic problem here is ASAN does not distinguish between illegal access from JVM caller code and legal access from within metaspace.
>
> The fixes required are minor. Without them even the ASAN build will fail. The ASAN errors are mostly caused by sections that are guarded with `MetaspaceTestInterval`.
>
> With the patch, ASAN build succeeds, and we survive metaspace gtests with `MetaspaceTestInterval` cranked up to the highest level.
Changes requested by gli (Committer).
src/hotspot/share/sanitizers/address.hpp line 65:
> 63: #define ASAN_ONLY(code)
> 64: #define NOT_ASAN(code) code
> 65: #define ASAN_POISON_MEMORY_REGION(addr, size) \
This preprocessing directive is for the macros `ASAN_POISON_MEMORY_REGION` and `ASAN_UNPOISON_MEMORY_REGION`. You can read the comment before `#ifdef ADDRESS_SANITIZER`. So it is good to place your code at another macro `#ifdef ADDRESS_SANITIZER`.
-------------
PR Review: https://git.openjdk.org/jdk/pull/18230#pullrequestreview-1933063622
PR Review Comment: https://git.openjdk.org/jdk/pull/18230#discussion_r1522408335
More information about the hotspot-runtime-dev
mailing list