Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
In certain cases, such as accessing a region of a memory mapped file which has been truncated on unix-style operating systems, a SIGBUS signal will be raised and the VM will handle it by throwing an error. However, the way this is implemented right now the VM isn't actually throwing the error synchronously. Instead, it is marking the thread as having a pending asynchronous exception, updating the context to skip over the faulting instruction, and then lets the thread continue executing. At specific points in the execution the VM checks if it's time to materialize and throw the error. Hence, between the time of the faulting instruction and the time when the error is thrown the thread may execute a (large) number of instructions which may or may not depend on the side effects of the faulting instruction. For example, on some platforms load instructions may update base pointers, set flags depending on the loaded value, etc. Since the faulting instruction was skipped over there is a risk that the (lack of) side effects from the skipped over instruction can in itself have unwanted side effects. The only operations which can access these regions (currently) are jdk.internal.misc.Unsafe (or sun.misc), which read and write single values in memory. For correctness, these unsafe operations should be handled synchronously. They should made to piggy back on the existing null checking exception infrastructure (but instead of SIGSEGV it's SIGBUS, and instead of a NullPointerException it's an InternalError).
|