United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-8000232 NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
JDK-8000232 : NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64

Details
Type:
Bug
Submit Date:
2012-09-28
Status:
Resolved
Updated Date:
2013-04-30
Project Name:
JDK
Resolved Date:
2012-10-06
Component:
hotspot
OS:
solaris
Sub-Component:
compiler
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
hs25
Fixed Versions:
hs25 (b05)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
Product VM with NPG changes crashes in Klass*Dependencies::DepStream::check_klass_dependency(KlassDepChange*) on solaris-x64 when -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation are used. 

Stack trace:
V  [libjvm.so+0x91367a]  Klass*Dependencies::DepStream::check_klass_dependency(KlassDepChange*)+0xc7e
V  [libjvm.so+0x7bdc47]  void ciEnv::validate_compile_task_dependencies(ciMethod*)+0x113
V  [libjvm.so+0x7bde97]  void ciEnv::register_method(ciMethod*,int,CodeOffsets*,int,CodeBuffer*,int,OopMapSet*,ExceptionHandlerTable*,ImplicitExceptionTable*,A
bstractCompiler*,int,bool)+0x1d7
V  [libjvm.so+0x67c082]  Compilation::Compilation(AbstractCompiler*,ciEnv*,ciMethod*,int,BufferBlob*)+0x8ea
V  [libjvm.so+0x67cd8f]  void Compiler::compile_method(ciEnv*,ciMethod*,int)+0x177
V  [libjvm.so+0x87d73b]  void CompileBroker::invoke_compiler_on_method(CompileTask*)+0xaaf
V  [libjvm.so+0x87c49a]  void CompileBroker::compiler_thread_loop()+0xac6
V  [libjvm.so+0x10f8729]  void JavaThread::run()+0x4cd
V  [libjvm.so+0xf024d6]  java_start+0x9d2
C  [libc.so.1+0xd704b]  _thr_setup+0x5b
C  [libc.so.1+0xd7280]  ht_pause+0x10
                                    

Comments
Crash doesn't occur with the pre-NPG binaries.

How to reproduce:
  $ javac -J-d64 -J-showversion -d . -J-XX:+UnlockDiagnosticVMOptions -J-XX:+WhiteBoxAPI -J-XX:+LogCompilation tests/sanity/WBApi.java

java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b57)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b03-internal-201209242322.vdanushe.emb-merge-to-hotsp, mixed mode)

  $ uname -a
SunOS intelsdv15 5.10 Generic_141445-09 i86pc i386 i86pc
                                     
2012-09-28
Stack trace in debugger:
=>[1] Dependencies::write_dependency_to(log = 0x4212a48, dept = unique_concrete_method, nargs = 2, args = 0xfffffd77fd3fdbb8, witness = 0xfffffd7ff00e3040), line 453 in "dependencies.cpp"
  [2] Dependencies::write_dependency_to(log = 0x4212a48, dept = unique_concrete_method, nargs = 2, args = 0xfffffd77fd3fdc88, witness = 0xfffffd7ff00e3040), line 440 in "dependencies.cpp"
  [3] Dependencies::DepStream::log_dependency(this = 0xfffffd77fd3fde10, witness = 0xfffffd7ff00e3040), line 580 in "dependencies.cpp"
  [4] Dependencies::DepStream::trace_and_log_witness(this = 0xfffffd77fd3fde10, witness = 0xfffffd7ff00e3040), line 1522 in "dependencies.cpp"
  [5] Dependencies::DepStream::check_klass_dependency(this = 0xfffffd77fd3fde10, changes = (nil)), line 1564 in "dependencies.cpp"
  [6] Dependencies::DepStream::check_dependency(this = 0xfffffd77fd3fde10), line 505 in "dependencies.hpp"
  [7] ciEnv::validate_compile_task_dependencies(this = 0xfffffd77fd3fe840, target = 0x4ec5fe8), line 882 in "ciEnv.cpp"
  [8] ciEnv::register_method(this = 0xfffffd77fd3fe840, target = 0x4ec5fe8, entry_bci = -1, offsets = 0xfffffd77fd3fe4d0, orig_pc_offset = 504, code_buffer = 0xfffffd77fd3fe4f8, frame_words = 66, oop_map_set = 0x4b83c18, handler_table = 0xfffffd77fd3fe488, inc_table = 0xfffffd77fd3fe4a8, compiler = 0x41a6b58, comp_level = 3, has_unsafe_access = false, has_wide_vectors = false), line 965 in "ciEnv.cpp"
  [9] Compilation::install_code(this = 0xfffffd77fd3fe410, frame_size = 132), line 353 in "c1_Compilation.cpp"
  [10] Compilation::compile_method(this = 0xfffffd77fd3fe410), line 407 in "c1_Compilation.cpp"
  [11] Compilation::Compilation(this = 0xfffffd77fd3fe410, compiler = 0x41a6b58, env = 0xfffffd77fd3fe840, method = 0x4ec5fe8, osr_bci = -1, buffer_blob = 0xfffffd7ff6388210), line 503 in "c1_Compilation.cpp"
  [12] Compiler::compile_method(this = 0x41a6b58, env = 0xfffffd77fd3fe840, method = 0x4ec5fe8, entry_bci = -1), line 110 in "c1_Compiler.cpp"
  [13] CompileBroker::invoke_compiler_on_method(task = 0x4995c38), line 1793 in "compileBroker.cpp"
  [14] CompileBroker::compiler_thread_loop(), line 1632 in "compileBroker.cpp"
  [15] compiler_thread_entry(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7ffe60a608
  [16] JavaThread::thread_main_inner(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7ffe6041c3
  [17] JavaThread::run(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7ffe603ff8
  [18] java_start(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7ffe415d18
  [19] _thr_setup(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff26cf5b
  [20] _lwp_start(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfffffd7fff26d190

Crash occurs in the following code:
   443 void Dependencies::write_dependency_to(CompileLog* log,
   444                                        DepType dept,
   445                                        int nargs, ciBaseObject* args[],
   446                                        Klass* witness) {
   447   if (log == NULL)  return;
   448   assert(nargs <= max_arg_count, "oob");
   449   int argids[max_arg_count];
   450   int ctxkj = dep_context_arg(dept);  // -1 if no context arg
   451   int j;
   452   for (j = 0; j < nargs; j++) {
   453     if (args[j]->is_object()) { <==== (args[0] == NULL)
   454       argids[j] = log->identify(args[j]->as_object());
   455     } else {
   456       argids[j] = log->identify(args[j]->as_metadata());
   457     }
   458   }

dept = unique_concrete_method, nargs = 2

(dbx) print witness->name()->as_C_string()
witness->name()->as_C_string() = 0x580eb08 "com/sun/tools/javac/code/Scope$CompoundScope"

      [2] Dependencies::write_dependency_to(log = 0x4212a48, dept = unique_concrete_method, nargs = 2, args = 0xfffffd77fd3fdc88, witness = 0xfffffd7ff00e3040), line 440 in "dependencies.cpp"
     
DepArgument args[2]: 
  (dbx) print args[0]
  args[0] = {
    _is_oop = false
    _valid  = true
    _value  = (nil)
  }
  (dbx) print args[1]
  args[1] = {
    _is_oop = false
    _valid  = true
    _value  = 0xfffffd7ffc879380
  }

NULL value comes from OopRecorder (Dependencies::DepStream::_deps->oop_recorder())

(dbx) frame 3
Current function is Dependencies::DepStream::log_dependency
  580       Dependencies::write_dependency_to(_deps->log(),

(dbx) print argument(0)
argument(0) = (nil)

(dbx) print argument(1)
argument(1) = 0xfffffd7ffc879380

(dbx) print recorded_metadata_at(argument_index(0))
recorded_metadata_at(argument_index(0)) = (nil)

inline Metadata* Dependencies::DepStream::recorded_metadata_at(int i) {
  Metadata* o = NULL;
  if (_code != NULL) {
    o = _code->metadata_at(i);
  } else {
    o = _deps->oop_recorder()->metadata_at(i);
  }
  assert(o == NULL || o->is_metadata(),
         err_msg("Should be perm " PTR_FORMAT, o));
  return o;
}

(dbx) print _code
_code = (nil)

(dbx) print _deps->oop_recorder()->metadata_at(0)
_deps->oop_recorder()->metadata_at(0) = (nil)

                                     
2012-09-28
Context of a dependency is encoded as NULL only when it is explicit and it's value is default (see Dependencies::ctxk_encoded_as_null). Decoding takes place only in Dependencies::DepStream::context_type(), however the value is used in other places.

The problem is that no decoding is performed when dependencies are
logged using Dependencies::write_dependency_to, but only non-NULL values are expected in the code.

The bug existed before NPG, it simply didn't cause a crash.

Fixed by moving decoding into Dependencies::DepStream::argument, so no caller could see encoded value (NULL) anymore.

It also improves TraceDependencies & LogCompilation output: dependency context is always correctly displayed.
                                     
2012-10-04
URL:   http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/9a9b6e05ffb4
User:  kvn
Date:  2012-10-06 05:33:54 +0000

                                     
2012-10-06
URL:   http://hg.openjdk.java.net/hsx/hsx25/hotspot/rev/9a9b6e05ffb4
User:  amurillo
Date:  2012-10-12 23:14:51 +0000

                                     
2012-10-12



Hardware and Software, Engineered to Work Together