Crash from upcall usage
Mark Hammons
markehammons at gmail.com
Sat Jan 29 19:56:56 UTC 2022
Running my tests with -XX:-UseCompiler lets me pass size 1,000,000 int
arrays to qsort successfully. I was never able to get that working with
compilation on. I'm going to test size 10,000,000 overnight, but I believe
this issue I encountered is related to JITing my lambdas.
On Sat, Jan 29, 2022 at 8:39 PM Mark Hammons <markehammons at gmail.com> 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