Thu, 17 Jul 2014 10:21:31 +0200
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
src/share/vm/code/nmethod.hpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/code/nmethod.hpp Tue Jul 22 07:35:52 2014 -0700 1.2 +++ b/src/share/vm/code/nmethod.hpp Thu Jul 17 10:21:31 2014 +0200 1.3 @@ -69,7 +69,12 @@ 1.4 friend class VMStructs; 1.5 private: 1.6 enum { cache_size = 4 }; 1.7 - PcDesc* _pc_descs[cache_size]; // last cache_size pc_descs found 1.8 + // The array elements MUST be volatile! Several threads may modify 1.9 + // and read from the cache concurrently. find_pc_desc_internal has 1.10 + // returned wrong results. C++ compiler (namely xlC12) may duplicate 1.11 + // C++ field accesses if the elements are not volatile. 1.12 + typedef PcDesc* PcDescPtr; 1.13 + volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found 1.14 public: 1.15 PcDescCache() { debug_only(_pc_descs[0] = NULL); } 1.16 void reset_to(PcDesc* initial_pc_desc);