Skip to content

IllegalArgumentException running Next.js 13 app-playground #5581

Closed as not planned

Description

@patrickpilch

Describe GraalVM and your environment :

  • GraalVM version or commit id if built from source: 22.3.0
  • CE or EE: CE
  • JDK version: 19
  • OS and OS Version: Ubuntu 22.04.1 LTS
  • Architecture: x86_64
  • The output of java -Xinternalversion:
 OpenJDK 64-Bit Server VM (19.0.1+10-jvmci-22.3-b08) for linux-amd64 JRE (19.0.1+10-jvmci-22.3-b08), built on 2022-10-19T11:11:18Z by "buildslave" with gcc 11.2.0

Have you verified this issue still happens when using the latest snapshot?
Yes, also verified with OpenJDK 64-Bit Server VM (19.0.1+10-jvmci-23.0-b04) for linux-amd64 JRE (19.0.1+10-jvmci-23.0-b04), built on 2022-12-01T21:10:15Z by "buildslave" with gcc 11.2.0

Describe the issue
An IllegalArgumentException is thrown when trying to launch Vercel's latest (as of 2022-12-07) "app-playground" example with Next.js 13.0.7-canary.1. See here for the specific commit.

Code snippet or code repository that reproduces the issue
Quick reproduction docker container:

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
  curl \ 
  build-essential \ 
  libz-dev \
  zlib1g-dev

#RUN curl -L https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java19-linux-amd64-22.3.0.tar.gz | tar xz
RUN curl -L https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/23.0.0-dev-20221206_2216/graalvm-ce-java19-linux-amd64-dev.tar.gz | tar xz

#ENV GRAALVM_HOME="/graalvm-ce-java19-22.3.0"
ENV GRAALVM_HOME="/graalvm-ce-java19-23.0.0-dev"
ENV PATH="$GRAALVM_HOME/bin:$PATH"
ENV JAVA_HOME="$GRAALVM_HOME"

RUN gu install nodejs

ENV PATH="$GRAALVM_HOME/languages/nodejs/bin:$PATH"

WORKDIR /root
RUN curl -L https://github.com/vercel/app-playground/tarball/92cb8b8992f805ea2934aadc582077ebfe33f549 | tar xz

WORKDIR /root/vercel-app-playground-92cb8b8
RUN npm install --global yarn && yarn install

CMD yarn dev

Steps to reproduce the issue

  1. Run docker build -t some_name . in the directory with the Dockerfile.
  2. Run the container to see the failure: docker run some_name

Expected behavior
Next.js development server should launch and start compiling and serving pages.

Output shown when attempting to launch.
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

*** NULL passed to FromJavaObject ***
java.lang.IllegalArgumentException: Invalid object handle
	at com.oracle.svm.core.jni.JNIObjectHandles.throwIllegalArgumentException(JNIObjectHandles.java:164)
	at com.oracle.svm.core.jni.JNIObjectHandles.getObjectSlow0(JNIObjectHandles.java:159)
	at com.oracle.svm.core.jni.JNIObjectHandles.getObjectSlow(JNIObjectHandles.java:152)
	at com.oracle.svm.core.jni.JNIObjectHandles.getObject(JNIObjectHandles.java:147)
	at com.oracle.svm.core.jni.JNIObjectHandles.newLocalRef(JNIObjectHandles.java:211)
	at com.oracle.svm.core.jni.functions.JNIFunctions.NewLocalRef(JNIFunctions.java:166)
	at com.oracle.truffle.trufflenode.NativeAccess.executeFunction2(NativeAccess.java)
	at com.oracle.truffle.trufflenode.node.ExecuteNativeFunctionNode.executeFunction2(ExecuteNativeFunctionNode.java:324)
	at com.oracle.truffle.trufflenode.node.ExecuteNativeFunctionNode.execute(ExecuteNativeFunctionNode.java:172)
	at com.oracle.truffle.trufflenode.node.ExecuteNativeFunctionNode$NativeFunctionRootNode.execute(ExecuteNativeFunctionNode.java:392)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:709)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:632)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:565)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:115)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:194)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:97)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:495)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:68)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$DirectJSFunctionCacheNode.executeCall(JSFunctionCallNode.java:1339)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode.executeAndSpecialize(JSFunctionCallNode.java:306)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode.executeCall(JSFunctionCallNode.java:251)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$InvokeNode.execute(JSFunctionCallNode.java:741)
	at com.oracle.truffle.js.nodes.control.ReturnNode$TerminalPositionReturnNode.execute(ReturnNode.java:178)
	at com.oracle.truffle.js.nodes.control.AbstractBlockNode.executeGeneric(AbstractBlockNode.java:85)
	at com.oracle.truffle.js.nodes.control.AbstractBlockNode.executeGeneric(AbstractBlockNode.java:55)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:80)
	at com.oracle.truffle.js.nodes.control.AbstractBlockNode.execute(AbstractBlockNode.java:75)
	at com.oracle.truffle.js.nodes.function.FunctionBodyNode.execute(FunctionBodyNode.java:73)
	at com.oracle.truffle.js.nodes.function.FunctionRootNode.executeInRealm(FunctionRootNode.java:152)
	at com.oracle.truffle.js.runtime.JavaScriptRealmBoundaryRootNode.execute(JavaScriptRealmBoundaryRootNode.java:96)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:709)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:632)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:565)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:115)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:194)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:97)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:495)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:68)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$DirectJSFunctionCacheNode.executeCall(JSFunctionCallNode.java:1339)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode.executeAndSpecialize(JSFunctionCallNode.java:306)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode.executeCall(JSFunctionCallNode.java:251)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$InvokeNode.execute(JSFunctionCallNode.java:741)
	at com.oracle.truffle.js.nodes.access.PropertyNode.evaluateTarget(PropertyNode.java:185)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$InvokeNode.executeTarget(JSFunctionCallNode.java:748)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$InvokeNode.execute(JSFunctionCallNode.java:737)
	at com.oracle.truffle.js.nodes.control.ReturnNode$TerminalPositionReturnNode.execute(ReturnNode.java:178)
	at com.oracle.truffle.js.nodes.control.AbstractBlockNode.executeGeneric(AbstractBlockNode.java:85)
	at com.oracle.truffle.js.nodes.control.AbstractBlockNode.executeGeneric(AbstractBlockNode.java:55)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:80)
	at com.oracle.truffle.js.nodes.control.AbstractBlockNode.execute(AbstractBlockNode.java:75)
	at com.oracle.truffle.js.nodes.control.AbstractGeneratorBlockNode.executeGeneric(AbstractGeneratorBlockNode.java:101)
	at com.oracle.truffle.js.nodes.control.AbstractGeneratorBlockNode.executeGeneric(AbstractGeneratorBlockNode.java:47)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:80)
	at com.oracle.truffle.js.nodes.control.AbstractGeneratorBlockNode.execute(AbstractGeneratorBlockNode.java:81)
	at com.oracle.truffle.js.nodes.control.AbstractGeneratorBlockNode.executeGeneric(AbstractGeneratorBlockNode.java:101)
	at com.oracle.truffle.js.nodes.control.AbstractGeneratorBlockNode.executeGeneric(AbstractGeneratorBlockNode.java:47)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedBlockNode.executeGeneric(OptimizedBlockNode.java:80)
	at com.oracle.truffle.js.nodes.control.AbstractGeneratorBlockNode.execute(AbstractGeneratorBlockNode.java:81)
	at com.oracle.truffle.js.nodes.function.FunctionBodyNode.execute(FunctionBodyNode.java:73)
	at com.oracle.truffle.js.nodes.control.AsyncFunctionBodyNode$AsyncFunctionRootNode.executeInRealm(AsyncFunctionBodyNode.java:138)
	at com.oracle.truffle.js.runtime.JavaScriptRealmBoundaryRootNode.execute(JavaScriptRealmBoundaryRootNode.java:96)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:709)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:632)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:565)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:115)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:194)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:97)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callIndirect(OptimizedCallTarget.java:477)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedIndirectCallNode.call(OptimizedIndirectCallNode.java:52)
	at com.oracle.truffle.js.nodes.function.InternalCallNode.indirectCall(InternalCallNode.java:76)
	at com.oracle.truffle.js.nodes.function.InternalCallNodeGen.execute(InternalCallNodeGen.java:45)
	at com.oracle.truffle.js.nodes.control.AwaitResumeNode.execute(AwaitResumeNode.java:69)
	at com.oracle.truffle.js.nodes.control.AbstractAwaitNode$AwaitSettledRootNode.execute(AbstractAwaitNode.java:293)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:709)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:632)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:565)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:115)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:194)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:97)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callIndirect(OptimizedCallTarget.java:477)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedIndirectCallNode.call(OptimizedIndirectCallNode.java:52)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode$GenericJSFunctionCacheNode.executeCall(JSFunctionCallNode.java:1691)
	at com.oracle.truffle.js.nodes.function.JSFunctionCallNode.executeCall(JSFunctionCallNode.java:247)
	at com.oracle.truffle.js.nodes.promise.PromiseReactionJobNode$PromiseReactionJobRootNode.execute(PromiseReactionJobNode.java:145)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:709)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:632)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:565)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:115)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:194)
	at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:97)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callIndirect(OptimizedCallTarget.java:477)
	at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.call(OptimizedCallTarget.java:458)
	at com.oracle.truffle.js.runtime.builtins.JSFunction.call(JSFunction.java:317)
	at com.oracle.truffle.js.runtime.JSAgent.processAllPromises(JSAgent.java:150)
	at com.oracle.truffle.trufflenode.GraalJSAccess.isolateRunMicrotasks(GraalJSAccess.java:3009)
Caused by: Attached Guest Language Frames (5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Activity

  1. wirthi commented on Dec 12, 2022

    @wirthi
    Member

    Hi,

    we had experienced a similar problem internally. Culprit was a binary (from @swc/core) passing a wrong argument to an NAPI function. The arguments had changed years back, but the binary was still passing extra arguments.

    Can you maybe check whether @swc/core is used in your example and might be triggering that?

    @woess @iamstolis (previous internal ticket was GR-39678)

  2. patrickpilch commented on Dec 14, 2022

    @patrickpilch
    Author

    @wirthi yarn why @swc/core doesn't yield anything, but I can confirm that next uses @next/swc-darwin-arm64
    I suspect I am seeing the same problem manifest differently on OS X arm64 and Ubuntu x86_64. See #5582 (comment)

  3. iamstolis commented on Dec 14, 2022

    @iamstolis
    Member

    This is a known issue of the native swc-related binary (next-swc.darwin-arm64.node in your case). This library is calling napi_create_async_work with an invalid third argument. The third argument is supposed to be napi_value but the library seems to pass const char* instead (in other words, it does not convert C string into a proper napi_string). V8 (the JavaScript engine in the original Node.js) is able to survive this mismatch somehow but graal-(node)js (correctly) reports it as an error. Unfortunately, it is not possible to workaround this mismatch on our side.

  4. added a commit that references this issue on Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions