FreeBSD 上的 OpenJDK:"Given reserved space must have been reserved already"

OpenJDK on FreeBSD: "Given reserved space must have been reserved already"

我正在尝试在 FreeBSD 机器上启动 Artifactory 和 运行。我安装了/usr/ports/devel/artifactory,貌似没问题,然后运行“/usr/local/etc/rc.d/artifactory启动”。它说 Artifactory 正在启动,并没有给出任何明显的错误迹象,但是当脚本结束时,Artifactory 不是 运行。我发现每次执行此操作时,都会将以下内容附加到 /usr/local/artifactory/logs/boot.log:

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (g1PageBasedVirtualSpace.cpp:54), pid=87801, tid=100176
#  guarantee(rs.is_reserved()) failed: Given reserved space must have been reserved already.

谷歌搜索 "Given reserved space must have been reserved already" 显示没有对我特别有用的信息。这似乎是来自 OpenJDK 内部的消息。

日志文件还提到创建了另一个包含更详细错误信息的文件。该文件有一个堆栈跟踪和各种其他信息:

---------------  T H R E A D  ---------------

Current thread (0x29cb0800):  JavaThread "Unknown thread" [_thread_in_vm, id=100176, stack(0xbf9be000,0xbf9fe000)]

Stack: [0xbf9be000,0xbf9fe000],  sp=0xbf9fd528,  free space=253k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x8234ed]  JVM_handle_bsd_signal+0x166bbd
V  [libjvm.so+0x36ef3f]  SUNWprivate_1.1+0x36ef3f
V  [libjvm.so+0x40df4c]  AsyncGetCallTrace+0x2c0bc
V  [libjvm.so+0x40def4]  AsyncGetCallTrace+0x2c064
V  [libjvm.so+0x40ff0b]  AsyncGetCallTrace+0x2e07b
V  [libjvm.so+0x41017e]  AsyncGetCallTrace+0x2e2ee
V  [libjvm.so+0x3f5874]  AsyncGetCallTrace+0x139e4
V  [libjvm.so+0x7ea485]  JVM_handle_bsd_signal+0x12db55
V  [libjvm.so+0x7ea105]  JVM_handle_bsd_signal+0x12d7d5
V  [libjvm.so+0x471291]  AsyncGetCallTrace+0x8f401
V  [libjvm.so+0x7cccd3]  JVM_handle_bsd_signal+0x1103a3
V  [libjvm.so+0x4d0eeb]  JNI_CreateJavaVM+0x6b
C  [java+0x3c35]  JavaMain+0x1d5
C  [libthr.so.3+0x76dc]  operator->+0x81c
C  0x00000000


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )

Other Threads:

=>0x29cb0800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=100176, stack(0xbf9be000,0xbf9fe000)]

VM state:not at safepoint (not fully initialized)

VM Mutex/Monitor currently owned by a thread:  ([mutex/lock_event])
[0x29c48640] Heap_lock - owner thread: 0x29cb0800

GC Heap History (0 events):
No events

Deoptimization events (0 events):
No events

Internal exceptions (0 events):
No events

Events (0 events):
No events


Dynamic libraries:
0x08048000      /usr/local/openjdk8/bin/java
0x2807d000      /lib/libz.so.6
0x28091000      /lib/libthr.so.3
0x280b3000      /lib/libc.so.7
0x28c00000      /usr/local/openjdk8/jre/lib/i386/server/libjvm.so
0x28237000      /lib/libm.so.5
0x2825d000      /usr/lib/libc++.so.1
0x2830c000      /lib/libcxxrt.so.1
0x28325000      /lib/libgcc_s.so.1
0x28331000      /usr/local/openjdk8/jre/lib/i386/libverify.so
0x2833d000      /usr/local/openjdk8/jre/lib/i386/libjava.so
0x2836a000      /usr/local/openjdk8/jre/lib/i386/libzip.so
0x28054000      /libexec/ld-elf.so.1

VM Arguments:
jvm_args: -Djava.util.logging.config.file=/usr/local/artifactory/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms512m -Xmx2g -Xss256k -XX:+UseG1GC -Djruby.compile.invokedynamic=false -Dfile.encoding=UTF8 -Dartdist=zip -Dartifactory.home=/usr/local/artifactory -Dfile.encoding=UTF8 -Djruby.compile.invokedynamic=false -Djava.endorsed.dirs=/usr/local/artifactory/tomcat/endorsed -Dcatalina.base=/usr/local/artifactory/tomcat -Dcatalina.home=/usr/local/artifactory/tomcat -Djava.io.tmpdir=/usr/local/artifactory/tomcat/temp
java_command: org.apache.catalina.startup.Bootstrap start
java_class_path (initial): /usr/local/artifactory/tomcat/bin/bootstrap.jar:/usr/local/artifactory/tomcat/bin/tomcat-juli.jar
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=/usr/local/openjdk8
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/nonexistent/bin
SHELL=/bin/csh
HOSTTYPE=FreeBSD
OSTYPE=FreeBSD
MACHTYPE=i386

Signal Handlers:
SIGSEGV: [libjvm.so+0x824280], sa_mask[0]=11111111111111111111111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGBUS: [libjvm.so+0x824280], sa_mask[0]=11111111111111111111111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGFPE: [libjvm.so+0x6b92f0], sa_mask[0]=11111111111111111111111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGPIPE: [libjvm.so+0x6b92f0], sa_mask[0]=11111111111111111111111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGXFSZ: [libjvm.so+0x6b92f0], sa_mask[0]=11111111111111111111111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGILL: [libjvm.so+0x6b92f0], sa_mask[0]=11111111111111111111111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGUSR1: SIG_DFL, sa_mask[0]=11111111011111110111111111111111, sa_flags=none
SIGUSR2: [libjvm.so+0x6b9fe0], sa_mask[0]=00000000000000000000000000000000, sa_flags=SA_RESTART|SA_SIGINFO
SIGHUP: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGINT: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGTERM: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGQUIT: SIG_DFL, sa_mask[0]=00000000000000000000000000000000, sa_flags=none


---------------  S Y S T E M  ---------------

OS:BSD
uname:FreeBSD 10.1-RELEASE FreeBSD 10.1-RELEASE #0 r274401: Tue Nov 11 22:51:51 UTC 2014     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC i386
rlimit: STACK 65536k, CORE infinity, NPROC 5547, NOFILE 94860, AS infinity
load average:0.26 0.19 0.80

CPU:total 8 (4 cores per cpu, 1 threads per core) family 6 model 26 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, tsc, tscinvbit, tscinv

Memory: 4k page, physical 3372996k(2931288k free), swap 13807988388243963904k(13807988392538586972k free)

vm_info: OpenJDK Server VM (25.60-b23) for bsd-x86 JRE (1.8.0_60-b24), built on Nov 14 2015 17:53:51 by "bob" with gcc 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)

time: Sat Nov 14 18:21:52 2015
elapsed time: 0 seconds (0d 0h 0m 0s)

所有包都是最新的并且是从源代码编译的。所有 Java 相关的东西都是新安装的(连同 Artifactory)并且默认配置没有改变。

有什么想法吗?谢谢

这似乎是内存分配的问题。 Artifactory 启动脚本中定义的默认堆大小为 2g,这超过了 32 位 FreeBSD 机器上 JVM 可以分配的 maximal heap 大小。
这种情况下的解决方案是将最大堆大小减小到 ~1.5g。