编译openjdk遇到的问题

编译jdk8,9都是成功的,但是运行的时候遇到了这个问题。

Error: A fatal exception has occurred. Program will exit.
localhost:bin jjchen$ ./java -version
openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-jjchen_2018_09_13_10_00-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x0000000107487f47, pid=88445, tid=0x0000000000002603
#
# JRE version: OpenJDK Runtime Environment (8.0) (build 1.8.0-internal-jjchen_2018_09_13_10_00-b00)
# Java VM: OpenJDK 64-Bit Server VM (25.71-b00 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# V  [libjvm.dylib+0x487f47]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/jjchen/jvm/jdk8u-dev/build/macosx-x86_64-normal-server-release/jdk/bin/hs_err_pid88445.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

把系统的libjvm.dylib 拷贝到jdk/lib/server中程序可以运行,说明是编译的jvm库出了问题。
后来调试的时候发现崩在了这个文件中的函数。/Users/jjchen/jvm/jdk8u-dev/hotspot/src/share/vm/runtime/perfData.cpp。把"delete p;"这行注释掉可以正常停止了。
这个问题花了好几天,记录一下。

void PerfDataManager::destroy() {

  if (_all == NULL)
    // destroy already called, or initialization never happened
    return;

  for (int index = 0; index < _all->length(); index++) {
    PerfData* p = _all->at(index);
    delete p;
  }

  delete(_all);
  delete(_sampled);
  delete(_constants);

  _all = NULL;
  _sampled = NULL;
  _constants = NULL;
}

推荐阅读更多精彩内容