Protecting the JVM from segfaults
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Apr 7 11:14:56 UTC 2021
On 07/04/2021 12:06, Maurizio Cimadamore wrote:
> he way the Foreign Memory Access API protects against SEGV is not by
> wrapping them as regular Java exception (I'm not sure how that would
> be possible in the general case)
To expand a bit more on that: we do have signal handlers installed by
the VM whenever we are accessing off-heap memory _already_.
The main problem with this strategy is that when you access memory
already freed, you are not _guaranteed_ to get a SEGV - if the memory
has been reallocated by somebody else, you might just end up silently
corrupting that memory. The same thing happens for access out of bounds
(you might accidentally access a piece of memory which is actually
accessible, but is not "for you to access").
In other words, I don't think the try/catch model works for these kind
of situations.
Maurizio
More information about the panama-dev
mailing list