From e19cf26d656bc2de947aa42c418bdbbf549f8865 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Fri, 5 May 2023 06:20:32 +0000 Subject: [PATCH] 8307196: Dangling pointer warning for MetadataAllocationRequest Reviewed-by: dholmes, eosterlund --- src/hotspot/share/memory/metaspaceCriticalAllocation.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hotspot/share/memory/metaspaceCriticalAllocation.cpp b/src/hotspot/share/memory/metaspaceCriticalAllocation.cpp index 8c067d215db..a25c4c68f10 100644 --- a/src/hotspot/share/memory/metaspaceCriticalAllocation.cpp +++ b/src/hotspot/share/memory/metaspaceCriticalAllocation.cpp @@ -79,12 +79,19 @@ void MetaspaceCriticalAllocation::add(MetadataAllocationRequest* request) { MutexLocker ml(MetaspaceCritical_lock, Mutex::_no_safepoint_check_flag); log_info(metaspace)("Requesting critical metaspace allocation; almost out of memory"); Atomic::store(&_has_critical_allocation, true); + // This is called by the request constructor to insert the request into the + // global list. The request's destructor will remove the request from the + // list. gcc13 has a false positive warning about the local request being + // added to the global list because it doesn't relate those operations. + PRAGMA_DIAG_PUSH + PRAGMA_DANGLING_POINTER_IGNORED if (_requests_head == nullptr) { _requests_head = _requests_tail = request; } else { _requests_tail->set_next(request); _requests_tail = request; } + PRAGMA_DIAG_POP } void MetaspaceCriticalAllocation::unlink(MetadataAllocationRequest* curr, MetadataAllocationRequest* prev) {