openjdk11{, -headless}: fix UB in markOop

OpenJDK 11 misuses the low bits in pointers that have an assumed
alignment. This is undefined behavior and compiler optimizations break
the code at runtime, causing SIGSEGV in the garbage collector.

This was originally noticed for clang13, but GCC15 seems to
do similar optimizations now. The UB was removed in JDK14.

See https://bugs.openjdk.org/browse/JDK-8229258

This is a smaller version of the unsuccessful backport PR proposed upstream:
https://github.com/openjdk/jdk11u-dev/pull/1284

Removed the .github/workflows changes and everything from the markOop to
markWord rename and file move from the patch. I found a way to avoid most
of the `markOopDesc`->`markOop` renames with a typedef, and dropped the
changes to all architectures besides x86 and aarch64.

Fixes: https://github.com/nixos/nixpkgs/issues/526834
This commit is contained in:
Stefan Nürnberger 2026-06-16 11:08:58 +02:00
commit e09bc37026
2 changed files with 2625 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -234,6 +234,9 @@ stdenv.mkDerivation (finalAttrs: {
else
./8/patches/swing-use-gtk-jdk8.patch
)
]
++ lib.optionals (featureVersion == "11") [
./11/patches/fix-oopdesc-ptr-alignment-ub.patch
];
strictDeps = true;