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
- add "-std=gnu17" to `env.NIX_CFLAGS_COMPILE` for `openjdk8` and `openjdk11`
Similar to what archlinux and gentoo did:
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=65ea75ab7b558c1a7471eaf9ab542cee66631ea5e2b65f230b87ced23f8b
Fixes build failure of `openjdk8` with gcc15:
```
In file included from /build/source/hotspot/agent/src/os/linux/libproc_impl.h:30,
from /build/source/hotspot/agent/src/os/linux/salibelf.h:30,
from /build/source/hotspot/agent/src/os/linux/salibelf.c:25:
/build/source/hotspot/agent/src/os/linux/libproc.h:86:13: error: 'bool'
cannot be defined via 'typedef'
86 | typedef int bool;
| ^~~~
/build/source/hotspot/agent/src/os/linux/libproc.h:86:13: note: 'bool'
is a keyword with '-std=c23' onwards
```
Fixes build failure of `openjdk11` with gcc15:
```
/build/source/src/java.base/unix/native/libnet/DefaultProxySelector.c:
In function 'getProxyByGProxyResolver':
/build/source/src/java.base/unix/native/libnet/DefaultProxySelector.c:389:16:
error: too many arguments to function 'g_proxy_resolver_lookup'; expected 0, have 4
389 | proxies = (*g_proxy_resolver_lookup)(resolver, uri, NULL, &error);
| ~^~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
/build/source/src/java.base/unix/native/libnet/DefaultProxySelector.c:408:34:
error: too many arguments to function 'g_network_address_parse_uri'; expected 0, have 3
408 | (*g_network_address_parse_uri)(proxies[i], 0,
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
```