When compiling with gcc13.1 for
When compiling with gcc13.1 for release we get some -Wdangling-pointer warnings like this (earlier versions of gcc don't warn):
In static member function 'static void MetaspaceCriticalAllocation::add(MetadataAllocationRequest*)',
inlined from 'MetadataAllocationRequest::MetadataAllocationRequest(ClassLoaderData*, size_t, Metaspace::MetadataType)' at ../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:53:37,
inlined from 'static MetaWordImpl** MetaspaceCriticalAllocation::allocate(ClassLoaderData*, size_t, Metaspace::MetadataType)' at ../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:208:65:
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:83:20: warning: storing the address of local variable 'request' in 'MetaspaceCriticalAllocation::_requests_head' [-Wdangling-pointer=]
83 | _requests_head = _requests_tail = request;
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp: In static member function 'static MetaWordImpl** MetaspaceCriticalAllocation::allocate(ClassLoaderData*, size_t, Metaspace::MetadataType)':
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:208:29: note: 'request' declared here
208 | MetadataAllocationRequest request(loader_data, word_size, type);
| ^~~~~~~
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:75:28: note: 'MetaspaceCriticalAllocation::_requests_head' declared here
75 | MetadataAllocationRequest* MetaspaceCriticalAllocation::_requests_head = nullptr;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Allocating a request (on the stack) adds the request to a global list, and the destructor removes the request from that list. The warning is a false positive, as the compiler is failing to relate those add/remove pairs.
When compiling with gcc13.1 for release we get some -Wdangling-pointer warnings like this (earlier versions of gcc don't warn):
In static member function 'static void MetaspaceCriticalAllocation::add(MetadataAllocationRequest*)',
inlined from 'MetadataAllocationRequest::MetadataAllocationRequest(ClassLoaderData*, size_t, Metaspace::MetadataType)' at ../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:53:37,
inlined from 'static MetaWordImpl** MetaspaceCriticalAllocation::allocate(ClassLoaderData*, size_t, Metaspace::MetadataType)' at ../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:208:65:
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:83:20: warning: storing the address of local variable 'request' in 'MetaspaceCriticalAllocation::_requests_head' [-Wdangling-pointer=]
83 | _requests_head = _requests_tail = request;
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp: In static member function 'static MetaWordImpl** MetaspaceCriticalAllocation::allocate(ClassLoaderData*, size_t, Metaspace::MetadataType)':
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:208:29: note: 'request' declared here
208 | MetadataAllocationRequest request(loader_data, word_size, type);
| ^~~~~~~
../../src/hotspot/share/memory/metaspaceCriticalAllocation.cpp:75:28: note: 'MetaspaceCriticalAllocation::_requests_head' declared here
75 | MetadataAllocationRequest* MetaspaceCriticalAllocation::_requests_head = nullptr;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Allocating a request (on the stack) adds the request to a global list, and the destructor removes the request from that list. The warning is a false positive, as the compiler is failing to relate those add/remove pairs.
- relates to
-
JDK-8307210 Dangling reference warnings for harfbuzz
-
- Open
-
-
JDK-8307147 [x86] Dangling pointer warning for Assembler::_attributes
-
- Resolved
-