java.lang.InternalError:最近在编译的Java代码中不安全的内存访问操作中发生了错误 [英] java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code
问题描述
我想知道某些JVM专家是否可以简要解释以下错误.从技术上讲,这实际上是什么意思,导致该错误的事件顺序是什么?
I was wondering if some of the JVM gurus out there can briefly explain the following error. What does it actually mean in technical terms and what are the sequences of events that can lead to this error?
java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code
推荐答案
此错误表示sun.misc.Unsafe.getX()
或putX()
内存访问导致
This error means that sun.misc.Unsafe.getX()
or putX()
memory access resulted in SIGBUS
error, which was then caught by JVM and translated to asynchronous InternalError
.
更多细节:
-
sun.misc.Unsafe
是JDK专用API,它允许直接从Java访问本机内存.该API是Direct ByteBuffers的基础,尤其是 MappedByteBuffers . -
在某些情况下,访问文件的内存映射区域可能会导致OS级异常,即
SIGBUS
.典型示例为:
sun.misc.Unsafe
is JDK private API that allows to access native memory directly from Java. This API is a foundation for Direct ByteBuffers and particularly MappedByteBuffers.In certain cases an access to memory-mapped region of a file may lead to OS-level exception, namely
SIGBUS
. Typical examples are:
- 基础文件被截断后,将访问内存映射的缓冲区.
- 网络驱动器上的文件已映射到内存,并且在网络连接丢失后可以访问映射的缓冲区.
- 尝试写入映射到
tmpfs
文件系统上文件的页面会导致内存不足(默认情况下,tmpfs
空间受限于总RAM的50%).
- A memory-mapped buffer is accessed after the underlying file has been truncated.
- A file on a network drive has been mapped to memory, and the mapped buffer is accessed after the network connection has been lost.
- An attempt to write to a page mapped to a file on
tmpfs
filesystem results in out-of-memory (by defaulttmpfs
space is limited by 50% of total RAM).
HotSpot JVM无法预先有效地检测到这些问题.它将Unsafe.getX / putX
调用编译为简单的内存访问指令.额外检查内存区域是否有效将太昂贵.
HotSpot JVM cannot efficiently detect these problems beforehand. It compiles Unsafe.getX / putX
calls to a simple memory access instruction. Additional checks to see if a memory region is valid would be too expensive.
See JDK-4454115 comments describing the solution for the related JDK bug.
这篇关于java.lang.InternalError:最近在编译的Java代码中不安全的内存访问操作中发生了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!