RFR: 8282306: os::is_first_C_frame(frame*) crashes on invalid link access [v5]

Thomas Stuefe stuefe at openjdk.java.net
Thu Feb 24 16:38:10 UTC 2022


On Thu, 24 Feb 2022 14:50:40 GMT, Johannes Bechberger <duke at openjdk.java.net> wrote:

>> This PR introduces a new method `can_access_link` into the frame class to check the accessibility of the link information. It furthermore adds a new `os::is_first_C_frame(frame*, Thread*)` that uses the `can_access_link` method
>> and the passed thread object to check the validity of frame pointer, stack pointer, sender frame pointer and sender stack pointer. This should reduce the possibilities for crashes.
>
> Johannes Bechberger has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix compile warnings

Looks almost good now. Small remarks remain.

src/hotspot/share/runtime/os.cpp line 1178:

> 1176: 
> 1177: // Looks like all platforms can use the same function to check if C
> 1178: // stack is walkable beyond current frame.

This comment is somewhat weird and it - and the one at the prototype in os.hpp - could do with some massaging. Buts its fine to do this in a different RFE.

src/hotspot/share/runtime/os.cpp line 1193:

> 1191: 
> 1192:   uintptr_t usp    = (uintptr_t)fr->sp();
> 1193:   if ((usp & sp_align_mask) != 0 || SafeFetchN(fr->sp(), (intptr_t)0) == 0) return true;

I'd use os::is_readable_ptr instead for easier readibility.

-------------

Changes requested by stuefe (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7591


More information about the hotspot-dev mailing list