RFR: 7903157: jextract crashes when header contains complex long double

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Apr 12 21:10:09 UTC 2022


Following the work in JDK-7903146, jextract crashes when encountering an header that contains a `long double complex`. As it turns out, this was a latent issue: the analysis in UnsupportedLayouts did not recursively follow a `DelegatedType`, unless its kind was a `typedef`.

There were reasons as to why the recursion was restricted: following pointers blindly can lead to infinite recursion (A points to B which points back to A). Butpointers are never problematic in terms of layout: the layout of a pointer is always fixed (given a platform), independently of what the pointee actually is.

So, the fix is for the analysis to be applied recursively to the delegated type, unless the type is a pointer type. This correctly detects `long double complex` (but also `atomic long double` etc.).

I could not add a test because our test framework ensures that tests cannot rely on standard headers (by forcing the `-C-nostdinc` flag on clang). This is problematic, because it is not possible to use complex types in C w/o including `<complex.h>`, at least not in a portable fashion (on Windows, MSVC does not support the `_Complex` keyword defined in C99 [1]).

[1] - https://docs.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support?view=msvc-170

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

Commit messages:
 - Tweak unsupported layout test to deal with all delegated types

Changes: https://git.openjdk.java.net/jextract/pull/20/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jextract&pr=20&range=00
  Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7903157
  Stats: 4 lines in 1 file changed: 1 ins; 0 del; 3 mod
  Patch: https://git.openjdk.java.net/jextract/pull/20.diff
  Fetch: git fetch https://git.openjdk.java.net/jextract pull/20/head:pull/20

PR: https://git.openjdk.java.net/jextract/pull/20


More information about the jextract-dev mailing list