RFR: 8289002: Minimal x86_64 VM build fails with GCC 11: 'this' pointer is null

Aleksey Shipilev shade at openjdk.org
Wed Aug 3 11:02:41 UTC 2022


On Wed, 3 Aug 2022 09:34:43 GMT, David Holmes <dholmes at openjdk.org> wrote:

> Now that doesn't help in the current situation where GCC complains about a NULL this ptr as it cannot know about the fact this code should be unreachable in practice. I'm tempted to say we should use guarantees in the VM code and abort if we encounter the NULL - would that satisfy GCC? 

I tried to put `guarantee()`-s or conditional `fatal()` on those paths, and this still does not please GCC. I think it is the recurrent problem with those methods not marked as `noreturn` . So it works if we put the `return`-s as well. Like this:


diff --git a/src/hotspot/share/services/diagnosticFramework.cpp b/src/hotspot/share/services/diagnosticFramework.cpp
index 31ef9d0061b..944e161c321 100644
--- a/src/hotspot/share/services/diagnosticFramework.cpp
+++ b/src/hotspot/share/services/diagnosticFramework.cpp
@@ -462,6 +462,10 @@ void DCmdFactory::send_notification_internal(TRAPS) {
   if (notif) {
 
     Klass* k = Management::com_sun_management_internal_DiagnosticCommandImpl_klass(CHECK);
+    if (k == nullptr) {
+      fatal("Should have the class");
+      return;
+    }
     InstanceKlass* dcmd_mbean_klass = InstanceKlass::cast(k);
 
     JavaValue result(T_OBJECT);
diff --git a/src/hotspot/share/services/memoryManager.cpp b/src/hotspot/share/services/memoryManager.cpp
index 38e308a8a15..d9527810e31 100644
--- a/src/hotspot/share/services/memoryManager.cpp
+++ b/src/hotspot/share/services/memoryManager.cpp
@@ -100,6 +100,11 @@ instanceOop MemoryManager::get_memory_manager_instance(TRAPS) {
       signature = vmSymbols::createMemoryManager_signature();
     }
 
+    if (k == nullptr) {
+      fatal("Should have the class");
+      return nullptr;
+    }
+
     InstanceKlass* ik = InstanceKlass::cast(k);
 
     JavaCalls::call_static(&result,


That would be okay with you, @dholmes-ora?

-------------

PR: https://git.openjdk.org/jdk/pull/9718


More information about the hotspot-dev mailing list