[foreign-jextract] [Rev 04] RFR: 8239128: Macro defines constant pointers can crash VM via jextract API

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Feb 21 21:31:25 UTC 2020


On Fri, 21 Feb 2020 20:40:08 GMT, Henry Jen <henryjen at openjdk.org> wrote:

>> The fundamental issue of the crash is that clang cursor/type may no longer valid after reparse another macro, and with pointer type lazily resolve the pointee type, if the clang cursor/type no longer valid, access invalid memory cause the crash.
>> 
>> The other issue is the a macro pointer to a record type like struct/union can cause NPE, and that cause the macro to be ignored on generation without a warning.
>> 
>> The fix remove the laziness from Type API perspective, but leave that as an implementation detail, so implementation of Pointer type need to figure out how to do that safely internally.
>> 
>> Record type in macro are reduces to void, as currently the Declaration implementation is depending on clang as well, we cannot guarantee that works after reparse.
> 
> The pull request has been updated with 1 additional commit.

Very good work; this improves not only the original crash, but also the efficiency of the clang usage in ways that we have never really been able to do with the old jextract. Thanks for taking the time to fix these issues!

src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/TreeMaker.java line 128:

> 127:         private final Cursor cursor;
> 128:         private final Path path;
> 129:         private final int line;

Very nice - this way we no longer depend on cursors ��

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

Marked as reviewed by mcimadamore (Committer).

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


More information about the panama-dev mailing list