From varadam at openjdk.org Wed Feb 4 10:10:53 2026 From: varadam at openjdk.org (Varada M) Date: Wed, 4 Feb 2026 10:10:53 GMT Subject: RFR: 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer [v7] In-Reply-To: References: Message-ID: > Total of 10 test failures observed on AIX: > jtreg/generator/nestedTypes/TestNestedTypesUnsupported.java > jtreg/generator/test8246400/LibTest8246400Test.java > jtreg/generator/test8258605/LibTest8258605Test.java > jtreg/generator/test8261511/Test8261511.java > jtreg/generator/testStruct/LibStructTest.java > testng/org/openjdk/jextract/test/toolprovider/ConstantsTest.java > testng/org/openjdk/jextract/test/toolprovider/IncompleteArrayTest.java > testng/org/openjdk/jextract/test/toolprovider/Test8240811.java > testng/org/openjdk/jextract/test/toolprovider/TestClassGeneration.java > testng/org/openjdk/jextract/test/toolprovider/nestedAnonOffset/TestNestedAnonOffset.java > > This PR fixes AIX specific layout generation issues related to incorrect alignment double and pointer types. > 1. Structs containing double fields fail with: > i. Unsupported layout: 4%D8 > ii. Invalid alignment constraint for member layout > double in AIX structs has size 8 but alignment 4 (except as first field). AIX specific handling for C_DOUBLE computes the correct alignment. > > 2. Clang was detected as 32-bit due to missing -m64 during macro extraction, causing inconsistent macros. This caused jextract to interpret pointer constants incorrectly, leading to failures like: > expected [-1] but found [4294967295] > > 3. TestNestedAnonOffset.java test failed on AIX because it also expects more padding similar to platforms like windows and linux > > > After the patch jtreg tests passes successfully. > > JBS: [CODETOOLS-7904115](https://bugs.openjdk.org/browse/CODETOOLS-7904115) Varada M has updated the pull request incrementally with one additional commit since the last revision: 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer ------------- Changes: - all: https://git.openjdk.org/jextract/pull/296/files - new: https://git.openjdk.org/jextract/pull/296/files/a3dbfaf9..49aebd79 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=296&range=06 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=296&range=05-06 Stats: 30 lines in 7 files changed: 8 ins; 14 del; 8 mod Patch: https://git.openjdk.org/jextract/pull/296.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/296/head:pull/296 PR: https://git.openjdk.org/jextract/pull/296 From varadam at openjdk.org Wed Feb 4 10:10:55 2026 From: varadam at openjdk.org (Varada M) Date: Wed, 4 Feb 2026 10:10:55 GMT Subject: RFR: 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer [v4] In-Reply-To: References: Message-ID: On Fri, 12 Dec 2025 17:03:56 GMT, Jorn Vernee wrote: >> Varada M has updated the pull request incrementally with one additional commit since the last revision: >> >> added field alignment and natural alignment argument > > Ok, the current approach means that jextract would only work when the C code is using natural alignment. If you're happy with that, I can accept the patch. But, all the of the changes I suggested are not needed in that case. > > I really think you should try to adjust `expectedAlign` in StructBuilder to get the right alignment (based on Maurizio's comment here: https://github.com/openjdk/jextract/pull/296#issuecomment-3564203711) Thank you @JornVernee and @mcimadamore for the earlier clarifications. I'm adding a consolidated explanation of the issue and current understanding. Failure case 1 : Invalid alignment constraint for member layout: D8(d) [in thread ?MainThread?] For this failing scenario, [AllTypes struct](https://github.com/openjdk/jextract/blob/master/test/jtreg/generator/testStruct/struct.h#L41), double is currently being aligned to 8 bytes by taking the struct alignment. This leads to cases where offset % align becomes invalid (eg: 52 % 8 != 0), which results in the exception. The correct approach here should be to calculate and respect the field alignment. Failure case 2 : expected [D8(d)] but found [4%D8(d)] & unsupported layout 4%D8 1) union bar2 { ? ?float f; ? ?double d; }; private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout( ? ? ? name_collision_h.C_FLOAT.withName("f"), ? ? ? ? MemoryLayout.valueLayout(8, java.nio.ByteOrder.nativeOrder()).withByteAlignment(4).withName("d") ? ? ).withName("bar2"); 2) ?* struct Vector { ?* ? ? double x; ?* ? ? double y; ?* } Vector; ?* ? ? private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( ? ? ? ? test8246400_h.align(test8246400_h.C_DOUBLE, 4).withName("x"), ? ? ? ? test8246400_h.align(test8246400_h.C_DOUBLE, 4).withName("y") ? ? ).withName("Vector"); ? ? In the above cases, C_DOUBLE is aligned to 4 bytes but we can?t alter the alignment of [C_DOUBLE layout](https://github.com/openjdk/jextract/blob/master/src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java#L262) (Thank you Jorn for clarifying that). modifying the fundamental alignment of C_DOUBLE would be incorrect and conflicts with the ABI expectations. Therefore, the safer and correct fix would be to adjust the specific test case to be fixed not to use C_DOUBLE. ------------- PR Comment: https://git.openjdk.org/jextract/pull/296#issuecomment-3846498472 From nbenalla at openjdk.org Wed Feb 4 16:40:48 2026 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 4 Feb 2026 16:40:48 GMT Subject: RFR: 7904128: Add a struct reinterpret helper that keeps scope Message-ID: Please review this change to add a new reinterpret method that keeps scope, I have removed one of the old methods and only kept one with arena and cleanup, and one without. ------------- Commit messages: - add new reinterpret method that keeps scope Changes: https://git.openjdk.org/jextract/pull/300/files Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=300&range=00 Issue: https://bugs.openjdk.org/browse/CODETOOLS-7904128 Stats: 24 lines in 3 files changed: 13 ins; 0 del; 11 mod Patch: https://git.openjdk.org/jextract/pull/300.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/300/head:pull/300 PR: https://git.openjdk.org/jextract/pull/300 From mcimadamore at openjdk.org Wed Feb 4 16:53:09 2026 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 4 Feb 2026 16:53:09 GMT Subject: RFR: 7904128: Add a struct reinterpret helper that keeps scope In-Reply-To: References: Message-ID: On Wed, 4 Feb 2026 16:27:04 GMT, Nizar Benalla wrote: > Please review this change to add a new reinterpret method that keeps scope, I have removed one of the old methods and only kept one with arena and cleanup, and one without. In general, the change seems good. I'm a bit unsure re. compatibility impact -- the test changes shows that there's some code out there that might stop working. If we want to play extra safe we could keep all existing methods, and add a new one. ------------- PR Review: https://git.openjdk.org/jextract/pull/300#pullrequestreview-3752138451 From varadam at openjdk.org Thu Feb 5 09:39:19 2026 From: varadam at openjdk.org (Varada M) Date: Thu, 5 Feb 2026 09:39:19 GMT Subject: RFR: 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer [v8] In-Reply-To: References: Message-ID: > Total of 10 test failures observed on AIX: > jtreg/generator/nestedTypes/TestNestedTypesUnsupported.java > jtreg/generator/test8246400/LibTest8246400Test.java > jtreg/generator/test8258605/LibTest8258605Test.java > jtreg/generator/test8261511/Test8261511.java > jtreg/generator/testStruct/LibStructTest.java > testng/org/openjdk/jextract/test/toolprovider/ConstantsTest.java > testng/org/openjdk/jextract/test/toolprovider/IncompleteArrayTest.java > testng/org/openjdk/jextract/test/toolprovider/Test8240811.java > testng/org/openjdk/jextract/test/toolprovider/TestClassGeneration.java > testng/org/openjdk/jextract/test/toolprovider/nestedAnonOffset/TestNestedAnonOffset.java > > This PR fixes AIX specific layout generation issues related to incorrect alignment double and pointer types. > 1. Structs containing double fields fail with: > i. Unsupported layout: 4%D8 > ii. Invalid alignment constraint for member layout > double in AIX structs has size 8 but alignment 4 (except as first field). AIX specific handling for C_DOUBLE computes the correct alignment. > > 2. Clang was detected as 32-bit due to missing -m64 during macro extraction, causing inconsistent macros. This caused jextract to interpret pointer constants incorrectly, leading to failures like: > expected [-1] but found [4294967295] > > 3. TestNestedAnonOffset.java test failed on AIX because it also expects more padding similar to platforms like windows and linux > > > After the patch jtreg tests passes successfully. > > JBS: [CODETOOLS-7904115](https://bugs.openjdk.org/browse/CODETOOLS-7904115) Varada M has updated the pull request incrementally with one additional commit since the last revision: Update examples.h ------------- Changes: - all: https://git.openjdk.org/jextract/pull/296/files - new: https://git.openjdk.org/jextract/pull/296/files/49aebd79..9b4aec96 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=296&range=07 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=296&range=06-07 Stats: 0 lines in 0 files changed: 0 ins; 0 del; 0 mod Patch: https://git.openjdk.org/jextract/pull/296.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/296/head:pull/296 PR: https://git.openjdk.org/jextract/pull/296