Integrated: 8365165: Zap C-heap memory at delete/free
Aleksey Shipilev
shade at openjdk.org
Mon Aug 18 08:15:16 UTC 2025
On Thu, 14 Aug 2025 10:16:52 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> We sometimes have a lifecycle problem with C-heap allocated objects. The most recent I dealt with is [JDK-8364501](https://bugs.openjdk.org/browse/JDK-8364501). It would be convenient to have diagnostic code to zap the memory that is freed on C heap. We already do this for alloc/realloc. When NMT is enabled (which it is for debug builds), we can also do this for frees, as NMT tells us the size of the free-ed block.
>
> This PR introduces a new diagnostic flag to match other `Zap*` flags we already have, puts the zapping on free path, and wraps alloc/realloc zapping with the flag as well. The last part is not really necessary, but it is nicer to wrap zapping code with a flag like this, so we can disable it for testing performance. JCStress routinely opts-out of most of the zapping to gain higher sampling throughput on fastdebug builds.
>
> Additional testing:
> - [x] Linux AArch64 server fastdebug, selectively rolling back [JDK-8364501](https://bugs.openjdk.org/browse/JDK-8364501) -- starts to immediately crash on reproducer
> - [x] Linux x86_64 server fastdebug, `all` (no new crashes, phew)
> - [x] Linux AArch64 server fastdebug, `all` (no new crashes, phew)
This pull request has now been integrated.
Changeset: ca753eba
Author: Aleksey Shipilev <shade at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/ca753ebad6681a76d18800d23898b7d6af83f567
Stats: 12 lines in 3 files changed: 9 ins; 0 del; 3 mod
8365165: Zap C-heap memory at delete/free
Reviewed-by: kvn, kbarrett
-------------
PR: https://git.openjdk.org/jdk/pull/26775
More information about the hotspot-runtime-dev
mailing list