[foreign-memaccess+abi] RFR: 8266626: Check that the target address of a native call is not NULL

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri May 7 13:58:42 UTC 2021


On Fri, 7 May 2021 13:40:10 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> This patch adds a check when unboxing the target address of a native call to check that the address is not `NULL`. Additionally, it adds checks earlier when an address is specified with a linking request, to check that that address is not `NULL`.
> 
> I didn't see any regressions on the CallOverhead* benchmarks.
> 
> Thanks,
> Jorn

Added some comments

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractCLinker.java line 46:

> 44:     private static void checkSymbol(Addressable symbol) {
> 45:         MemoryAddress symbolAddr = symbol.address();
> 46:         if (symbolAddr.equals(MemoryAddress.NULL))

Do we already NPE for `null` ?

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractCLinker.java line 47:

> 45:         MemoryAddress symbolAddr = symbol.address();
> 46:         if (symbolAddr.equals(MemoryAddress.NULL))
> 47:             throw new IllegalArgumentException("Symbol is NULL: " + symbolAddr);

IAE or NPE?

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/ProgrammableInvoker.java line 177:

> 175:     private static long unboxTargetAddress(Addressable addr) {
> 176:         MemoryAddress ma = addr.address();
> 177:         if (ma.equals(MemoryAddress.NULL)) {

Why not reusing checkSymbol?

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

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


More information about the panama-dev mailing list