< prev index next >

src/hotspot/share/runtime/stubCodeGenerator.hpp

Print this page
rev 51308 : 8206267: Unsafe publication of StubCodeDesc leads to crashes
Reviewed-by: kvn

@@ -25,10 +25,11 @@
 #ifndef SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
 #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
 
 #include "asm/assembler.hpp"
 #include "memory/allocation.hpp"
+#include "runtime/orderAccess.hpp"
 
 // All the basic framework for stub code generation/debugging/printing.
 
 
 // A StubCodeDesc describes a piece of generated code (usually stubs).

@@ -36,11 +37,11 @@
 // Currently, code descriptors are simply chained in a linked list,
 // this may have to change if searching becomes too slow.
 
 class StubCodeDesc: public CHeapObj<mtCode> {
  private:
-  static StubCodeDesc* _list;                  // the list of all descriptors
+  static StubCodeDesc *volatile _list;         // the list of all descriptors
   static bool          _frozen;                // determines whether _list modifications are allowed
 
   StubCodeDesc*        _next;                  // the next element in the linked list
   const char*          _group;                 // the group to which the stub code belongs
   const char*          _name;                  // the name assigned to the stub code

@@ -74,11 +75,11 @@
     _next           = _list;
     _group          = group;
     _name           = name;
     _begin          = begin;
     _end            = end;
-    _list           = this;
+    OrderAccess::release_store(&_list, this);
   };
 
   static void freeze();
 
   const char* group() const                      { return _group; }
< prev index next >