[jdk23u] RFR: 8337753: Target class of upcall stub may be unloaded
pabloko
duke at openjdk.org
Fri Oct 25 22:10:09 UTC 2024
On Mon, 14 Oct 2024 12:34:18 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Backport of: https://github.com/openjdk/jdk/pull/20479
>
> There were some trivial conflicts in `stubGenerator_aarch64.cpp` and `stubGenerator_riscv.cpp`. Some code still there in jdk23, already removed in later versions.
Yeah, i've spent a good time triying to isolate and reproduce the issue to do a bugreport without much success, but definitely we're behind of this for some months now as we early and widely adopted FFM back on jdk19.
In our case, we have calls originating from a remote thread pool from 3rd party library, wich is a fairly common use case.
We had initially checked that the native code is not producing exceptions and the same for the java code, in fact, we wrap our MethodHandle lookups like this to avoid possible java exceptions.
return MethodHandles.catchException(MethodHandles.lookup().findVirtual(obj.getClass(), methodName, functionDescriptor.toMethodType()), Throwable.class, MethodHandles.empty(MethodType.methodType(functionDescriptor.toMethodType().returnType(), Throwable.class))).bindTo(obj)
Later we observed that different combinations of threading while allocating upcalls with `Arena.ofShared()` would crash the jvm on `System.gc()` but `Arena.ofAuto()` would not, but still crash randomly at some point... We also tried a variety of testing flags like SafepointALot/HandshakeALot and similar ones without any noticeable effects, and at that point we stated considering a jdk implementation bug and following the rabbit hole until we seen the [commit log](https://github.com/openjdk/jdk/pull/20479) of the original PR, and it all made sense.
In any case, we're available to conduct any further testing needed to resolve the issue since we're still able to trigger it Additionally, we confirm that this PR seems to fix it effectively in our ad-hoc builds.
-------------
PR Comment: https://git.openjdk.org/jdk23u/pull/163#issuecomment-2438945591
More information about the jdk-updates-dev
mailing list