[讨论] 求问JVM参数解析问题

yuyinyang 2013-03-18
R大,那个编译的问题编过了我就没再管它了,我按照你前面介绍的参数解析过程把相关的代码都看了,然后我在runtime/globals.hpp里定义了一个新的参数
/* gc */                                                                 \
                                                                             \
product(bool, UseMyGC, false,                               \
          "Use the my garbage collector")                   \
                                                                             \  
product(bool, UseSerialGC, false,                          \
          "Use the serial garbage collector")               \

//...

然后编译的话报了下面的错误
Using java runtime at: /usr/lib/jvm/java-openjdk/jre
引用
#
# A fatal error has been detected by the Java Runtime Environment:#
#  Internal Error (globals.cpp:374), pid=20750, tid=140406270584576#  guarantee(faddr != NULL && faddr->is_uintx()) failed: wrong flag type
#
# JRE version: 6.0_24-b24
# Java VM: OpenJDK 64-Bit Server VM (21.0-b17 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#...

我查看了错误日志,里面打印出了调用栈的信息
引用
---------------  T H R E A D  ---------------

Current thread is native thread
Stack: [0x00007fb2e1d1e000,0x00007fb2e1e1f000],  sp=0x00007fb2e1e1c9b0,  free space=1018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)V  [libjvm.so+0x7fbd09]  VMError::report_and_die()+0x169
V  [libjvm.so+0x3ca13a]  report_vm_error(char const*, int, char const*, char const*)+0x4a
V  [libjvm.so+0x471be0]  CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType, unsigned long, FlagValueOrigin)+0x60
V  [libjvm.so+0x21d1e3]  Arguments::set_heap_size()+0x173
V  [libjvm.so+0x221540]  Arguments::parse(JavaVMInitArgs const*)+0x5f0
V  [libjvm.so+0x7bdf0d]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x8d
V  [libjvm.so+0x5028aa]  JNI_CreateJavaVM+0x5a
C  [gamma+0x517b]  getenv@@GLIBC_2.2.5+0x517b
C  [gamma+0x3adb]  JavaMain+0xc1


我的想法是,这上面的错误信息应该是bootstrap jdk运行openjdk 7报出的错误信息,由于我添加的UseMyGC参数在bootstrap jdk中的flagTable中并不存在,所以它在CommandLineFlagsEx::uintxAtPut函数中调用Flag* faddr = address_of_flag(flag)时返回了null。但是我不太清楚为什么Arguments::set_heap_size()会出现在错误栈信息中,它并没有调用CommandLineFlagsEx::uintxAtPut这个方法。
不知道我的想法是否正确?如果真是这样的话,有没有办法可以在openjdk里添加新的JVM参数呢?
RednaxelaFX 2013-03-18
往globals.hpp里添加新参数,如果你只添加声明而没在别的地方用它的话几乎没可能出错,这种事情我经常做…
请把你使用的源码的具体版本(假定你是用hg下载的)、hg diff和完整的crash log贴一下。
yuyinyang 2013-03-18
我是直接在http://download.java.net/openjdk/jdk7/下载的源码包,版本是openjdk-7-fcs-src-b147-27_jun_2011.zip
我只做了声明。。
引用
[19:04 ..c/share/vm/runtime] git l1 -1 -p
9528ae1 Add a command-line VM argument UseMyGC.
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index 9943f48..f998c3f 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -1346,6 +1346,9 @@ class CommandLineFlags {
                                                                             \
   /* gc */                                                                  \
                                                                             \
+  product(bool, UseMyGC, false,                                                    \
+         "Use the my garbage collector")                                 \
+                                                                           \
   product(bool, UseSerialGC, false,                                         \
           "Use the serial garbage collector")                               \
                                                                             \

crash log在http://yuyinyang.iteye.com/blog/1831401
RednaxelaFX 2013-03-18
1、你用干净的OpenJDK7源码啥也不改在你的环境里build一次的话会crash不?

2、每次修改过globals.hpp之后都一定,是一定要做clean build而不要做incremental build,后者很大机会出现诡异问题。

3、另外你也可以试试就用这个会crash的版本不clean直接再make一次(保留之前已经build出来的那些文件)。方法是在这个路径下 /home/yuyinyang/workspace/openjdk/build/openjdk-full-debug/hotspot/outputdir/linux_amd64_compiler2/product 添加一个文件:.hotspotrc,内容是
+ShowMessageBoxOnError

添加好这个文件后再make,如果VM crash了的话会自动挂一个gdb上去方便调试。
yuyinyang 2013-03-19
1、干净的OpenJDK7源码啥也不改build可以通过,不会crash的
2、按照您说的clean之后再make,顺利通过,感叹一句,R大真心太牛逼了
3、不知道为什么,这个gdb启动后命令都不好用
引用
...
Missing separate debuginfos, use: debuginfo-install glibc-2.14.90-24.fc16.9.x86_64 java-1.6.0-openjdk-1.6.0.0-71.1.11.6.fc16.x86_64
(gdb) thread 139790463624960
Thread ID -2131925248 not known.
(gdb) stack
Undefined command: "stack".  Try "help".
(gdb) breakpoints
Undefined command: "breakpoints".  Try "help".
(gdb) help
List of classes of commands:

aliases -- Aliases of other commandsbreakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commandsobscure -- Obscure featuresrunning -- Running the programstack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands

Type "help" followed by a class name for a list of commands in that class.Type "help all" for the list of all commands.
...
RednaxelaFX 2013-03-19
yuyinyang 写道
1、干净的OpenJDK7源码啥也不改build可以通过,不会crash的

这样就可以知道至少你的build环境没问题

yuyinyang 写道
2、按照您说的clean之后再make,顺利通过,感叹一句,R大真心太牛逼了

跟牛逼啥的没关系,只是做HotSpot VM开发的话大家迟早都会踩一次这个坑。我这边build一次也就3分钟,如果我改过头文件的话就肯定会做一次clean build,免得出了诡异问题还得慢慢找原因。人懒,呵呵…

yuyinyang 写道
3、不知道为什么,这个gdb启动后命令都不好用
引用
...
Missing separate debuginfos, use: debuginfo-install glibc-2.14.90-24.fc16.9.x86_64 java-1.6.0-openjdk-1.6.0.0-71.1.11.6.fc16.x86_64
(gdb) thread 139790463624960
Thread ID -2131925248 not known.
(gdb) stack
Undefined command: "stack".  Try "help".
(gdb) breakpoints
Undefined command: "breakpoints".  Try "help".
(gdb) help
List of classes of commands:

aliases -- Aliases of other commandsbreakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commandsobscure -- Obscure featuresrunning -- Running the programstack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands

Type "help" followed by a class name for a list of commands in that class.Type "help all" for the list of all commands.
...

前面省略的部分或许说明了原因…可能有啥报错信息你看漏了
yuyinyang 2013-03-19
RednaxelaFX 写道
跟牛逼啥的没关系,只是做HotSpot VM开发的话大家迟早都会踩一次这个坑。

学长您过谦了,小弟比您低了三届也是nju se的。。咱nju的就是低调。。
RednaxelaFX 写道
我这边build一次也就3分钟,如果我改过头文件的话就肯定会做一次clean build,免得出了诡异问题还得慢慢找原因。人懒,呵呵…

这个是指任何头文件吗?修改了哪些文件需要重新clean build呢?
RednaxelaFX 写道
前面省略的部分或许说明了原因…可能有啥报错信息你看漏了

我翻了下前面的信息貌似没什么特别奇怪的。。
引用
[09:36 .._compiler2/product] gdb /proc/8107/exe 8107
GNU gdb (GDB) Fedora (7.3.50.20110722-16.fc16)
Copyright (C) 2011 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /proc/8107/exe...done.
Attaching to program: /proc/8107/exe, process 8107
Reading symbols from ./libjvm.so...(no debugging symbols found)...done.
Loaded symbols for ./libjvm.so
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libm.so.6
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7f2380ed6700 (LWP 8108)]Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libverify.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libverify.so
Reading symbols from /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libjava.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libjava.so
Reading symbols from /lib64/libnsl.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libnsl.so.1
0x000000318ba09080 in pthread_join () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.14.90-24.fc16.9.x86_64 java-1.6.0-openjdk-1.6.0.0-71.1.11.6.fc16.x86_64
(gdb) thread 139790463624960
Thread ID -2131925248 not known.
(gdb) stack
Undefined command: "stack".  Try "help".
(gdb) breakpoints
Undefined command: "breakpoints".  Try "help".(gdb) help
List of classes of commands:
...
RednaxelaFX 2013-03-19
yuyinyang 写道
RednaxelaFX 写道
跟牛逼啥的没关系,只是做HotSpot VM开发的话大家迟早都会踩一次这个坑。

学长您过谦了,小弟比您低了三届也是nju se的。。咱nju的就是低调。。

喔呵呵…有学弟对HotSpot VM感兴趣,不错!

yuyinyang 写道
RednaxelaFX 写道
我这边build一次也就3分钟,如果我改过头文件的话就肯定会做一次clean build,免得出了诡异问题还得慢慢找原因。人懒,呵呵…

这个是指任何头文件吗?修改了哪些文件需要重新clean build呢?

任何头文件。其实会出现诡异问题多半是跟precompiled header相关,可以通过编译参数来禁用掉PCH。但禁用了PCH的话普通的incremental build就会慢一些所以我又不想禁用。

yuyinyang 写道
RednaxelaFX 写道
前面省略的部分或许说明了原因…可能有啥报错信息你看漏了

我翻了下前面的信息貌似没什么特别奇怪的。。
引用
[09:36 .._compiler2/product] gdb /proc/8107/exe 8107
GNU gdb (GDB) Fedora (7.3.50.20110722-16.fc16)
Copyright (C) 2011 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /proc/8107/exe...done.
Attaching to program: /proc/8107/exe, process 8107
Reading symbols from ./libjvm.so...(no debugging symbols found)...done.
Loaded symbols for ./libjvm.so
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libm.so.6
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7f2380ed6700 (LWP 8108)]Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libverify.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libverify.so
Reading symbols from /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libjava.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/libjava.so
Reading symbols from /lib64/libnsl.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libnsl.so.1
0x000000318ba09080 in pthread_join () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.14.90-24.fc16.9.x86_64 java-1.6.0-openjdk-1.6.0.0-71.1.11.6.fc16.x86_64
(gdb) thread 139790463624960
Thread ID -2131925248 not known.
(gdb) stack
Undefined command: "stack".  Try "help".
(gdb) breakpoints
Undefined command: "breakpoints".  Try "help".(gdb) help
List of classes of commands:
...

能不能试试一些常用命令,例如info threads、bt之类?光看前面的记录没看出啥问题。
Global site tag (gtag.js) - Google Analytics