JDK-8153892 : Handle unsafe access error directly in signal handler instead of going through a stub
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-04-08
  • Updated: 2025-10-16
  • Resolved: 2016-05-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b120Fixed
Related Reports
Relates :  
Relates :  
Description
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 process it in the signal handler.

How the signal is processed differs depending on the operating system and/or CPU architecture, with two major alternatives:

* "stubless"

Do the necessary thread state updates directly in the signal handler, and modify the context so that the signal handler returns to the place where the execution should continue 

* Using a stub

Update the context so that when the signal handler returns the thread will continue execution in a generated stub, which in turn will call some native code in the VM to update the thread state and figure out where execution should continue. The stub will then jump to that new place.


It should be noted that the work of updating the thread state is very small - it's setting a flag or two in the thread structure, and figures out where the next instruction starts. It should also be noted that the generated stubs today are broken, because they do not preserve all the live registers over the call into the VM. There are two ways to address this:

* Preserve all the necessary registers

This would mean implementing, in macro assembly, the necessary logic for preserving all the live registers, including, but not limited to, floating point registers, flag registers, etc. It quickly becomes obvious that this platform specific and error prone.

* Leverage the fact that the operating system already does this as part of the signal handling

Do the necessary work in the signal handler instead, removing the need for the stub alltogether

As mentioned, on some platforms the latter model is already in use. It is dramatically easier and all platforms should be updated to do it the same way.
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/f2916653b884 User: lana Date: 2016-05-25 17:36:48 +0000
25-05-2016

URL: http://hg.openjdk.java.net/jdk9/hs/hotspot/rev/f2916653b884 User: dcubed Date: 2016-05-03 16:36:11 +0000
03-05-2016

Which platforms use which technique? There are likely reasons why the two approaches had to be used.
11-04-2016