Skip to content

Commit 2bcf797

Browse files
committed
chunk zap when returning chunk to chunk manager
1 parent d49b3ea commit 2bcf797

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/hotspot/share/memory/metaspace/chunkManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ Metachunk* ChunkManager::get_chunk_locked(chunklevel_t preferred_level, chunklev
243243
// !! Note: this may invalidate the chunk. Do not access the chunk after
244244
// this function returns !!
245245
void ChunkManager::return_chunk(Metachunk* c) {
246+
DEBUG_ONLY(c->zap();)
246247
// It is valid to poison the chunk payload area at this point since its physically separated from
247248
// the chunk meta info.
248249
ASAN_POISON_MEMORY_REGION(c->base(), c->word_size() * BytesPerWord);

src/hotspot/share/memory/metaspace/metachunk.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "memory/metaspace/metachunk.hpp"
2828
#include "memory/metaspace/metaspaceCommon.hpp"
2929
#include "memory/metaspace/metaspaceSettings.hpp"
30+
#include "memory/metaspace/metaspaceZapper.hpp"
3031
#include "memory/metaspace/virtualSpaceNode.hpp"
3132
#include "runtime/mutexLocker.hpp"
3233
#include "runtime/os.hpp"
@@ -183,6 +184,12 @@ void Metachunk::zap_header(uint8_t c) {
183184
memset(this, c, sizeof(Metachunk));
184185
}
185186

187+
// Zaps the chunk itself
188+
void Metachunk::zap() {
189+
// Only committed portion, obviously
190+
Zapper::zap_memory(base(), committed_words());
191+
}
192+
186193
// Verifies linking with neighbors in virtual space.
187194
// Can only be done under expand lock protection.
188195
void Metachunk::verify_neighborhood() const {

src/hotspot/share/memory/metaspace/metachunk.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ class Metachunk {
340340
void verify() const;
341341
// Verifies linking with neighbors in virtual space. Needs expand lock protection.
342342
void verify_neighborhood() const;
343+
// Zaps the header (this structure); Note: physically disjunct from the actual chunk!
343344
void zap_header(uint8_t c = 0x17);
345+
// Zaps the chunk itself
346+
void zap();
344347

345348
// Returns true if given pointer points into the payload area of this chunk.
346349
bool is_valid_pointer(const MetaWord* p) const {

0 commit comments

Comments
 (0)