[foreign-memaccess+abi] RFR: 8267989: Exceptions thrown during upcalls should be handled [v2]

Jorn Vernee jvernee at openjdk.java.net
Tue Jun 1 12:05:27 UTC 2021


On Mon, 31 May 2021 18:43:17 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Hi,
>> 
>> This patch regularizes exception handling for exceptions thrown during upcalls. Exceptions thrown during upcalls are now always handled by printing out the stack trace and then calling `System::exit` (see the JBS issue for some motivation).
>> 
>> I've added some documentation for the exception handling to `CLinker::upcallStub`, as well as a new public `int` constant in `CLinker` which is the error code that is passed to `System::exit`. The returned error code can also be configured by a system property, which for now is mostly useful for testing purposes to make sure we don't get a consistent false positive.
>> 
>> Thanks,
>> Jorn
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Address review comments:
>   - tweak documentation
>   - remove system property
>   - simplify test & check stderr for stack trace message

I've switched to using `Shutdown.exit`, and added a `SecurityManager` that blocks the normal `System.exit` call into the test. I've also switched `CABI` from using `System.getProperty` to determine the platform, to using `priviledgedGetProperty`, to avoid any security exceptions (found during testing).

I've removed the public `ERR_UNCAUGHT_EXCEPTION` constant, and changed the documentation to say that the VM will exit with a non-zero exit status in the case of an uncaught exception.

Finally, I've changed the test to always print the output as well, besides checking the contents.

I still have to add an eager check (and test) to see if the target of an upcall throws an exception.

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

PR: https://git.openjdk.java.net/panama-foreign/pull/543


More information about the panama-dev mailing list