# HG changeset patch # User mdoerr # Date 1405585291 -7200 # Node ID 63e0c47ca943c9ff10441e084ad302060bc1bba5 # Parent 6ad19ab9417663fca11049b4ede256be61ba2ba2 8050972: Concurrency problem in PcDesc cache Summary: The entries of the PcDesc cache in nmethods are not declared as volatile, but they are accessed and modified by several threads concurrently. Reviewed-by: kvn, dholmes, dcubed diff -r 6ad19ab94176 -r 63e0c47ca943 src/share/vm/code/nmethod.hpp --- a/src/share/vm/code/nmethod.hpp Tue Jul 22 07:35:52 2014 -0700 +++ b/src/share/vm/code/nmethod.hpp Thu Jul 17 10:21:31 2014 +0200 @@ -69,7 +69,12 @@ friend class VMStructs; private: enum { cache_size = 4 }; - PcDesc* _pc_descs[cache_size]; // last cache_size pc_descs found + // The array elements MUST be volatile! Several threads may modify + // and read from the cache concurrently. find_pc_desc_internal has + // returned wrong results. C++ compiler (namely xlC12) may duplicate + // C++ field accesses if the elements are not volatile. + typedef PcDesc* PcDescPtr; + volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found public: PcDescCache() { debug_only(_pc_descs[0] = NULL); } void reset_to(PcDesc* initial_pc_desc);