Crash from upcall usage
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Jan 31 10:52:27 UTC 2022
Hi Mark,
have you tried using the latest Panama EA binaries?
Or, JDK 18?
There was an issue with upcall crashing the VM first spotted in Apache
Tomcat. If you are running an older build (and the Panama 17 EA is one
of those) you might be affected by that.
Maurizio
On 29/01/2022 19:39, Mark Hammons wrote:
> Hi Panama team,
>
> I was testing my library earlier today, and I noticed that when I call
> qsort with integer arrays of size 10000 or greater, I have an increasing
> chance (not 100% at 10000) of a jvm crash. I downloaded and used OpenJDK
> 64-Bit Server VM (build 17-panama+3-167, mixed mode, sharing)
> and reran my tests and I think that the crash is being triggered by C2
> compilation of a lambda I'm passing to qsort, but I'm not certain.
>
> I've attached the error report and compilation logs of my program.
>
>
> https://gitlab.com/mhammons/slinc/-/blob/44-crash-on-qsort-benchmarks-when-using-values-larger-than-10000/cstd/test/src/io/gitlab/mhammons/cstd/StdLibSuite.scala#L86
> is
> the test that crashes. You can run it by running ./mill cstd.test in a
> cloned directory.
>
> My library is passing scala lambdas in by generating a lambda (Any, Any) =>
> Any that takes the input parameters from foreign and converts them into the
> expected types, and converts the output of the original lambda into a
> foreign compatible type. This generated lambda is then bound to a method
> handle by Using a findVirtual lookup of the appropriate function class,
> describing the lambda to the MethodHandle system, and calling asType with
> the method handle type that foreign is expecting.
>
> val lambdaMh: MethodHandle = MethodHandles.lookup
> .findVirtual(
> $classRepr,
> "apply",
> MT.genericMethodType(${ Expr(inputTypes.size) })
> )
> .bindTo($wrappedLambda)
> .asType(methodType)
>
> Linker.linker.upcallStub(
> lambdaMh,
> functionDescriptor,
> currentScope
> )
> This code is using macros to create the appropriate lambda types and such,
> so it can be a bit hard to read. In any case, the method handle created
> this way is then passed into upcallStub. I'm not sure if this is actually a
> bug in my library, and I'd like your help in debugging this crash.
>
> Thanks so much,
> Mark
More information about the panama-dev
mailing list