oracle / graaljs

GraalJS – A high-performance, ECMAScript compliant, and embeddable JavaScript runtime for Java
https://www.graalvm.org/javascript/
Universal Permissive License v1.0
1.81k stars 190 forks source link

Exceptions raised whilst debugging a polyglot node application #256

Closed krisfoster closed 4 years ago

krisfoster commented 4 years ago

Whilst running this Node application, see link below, and running the polyglot-javascript-java-r node application, exceptions are generated whilst debugging.

https://github.com/graalvm/graalvm-demos

My set up: I am running the application within an Ubunutu WLS. I am using Visual Studio Code (1.42.1) and have the GraalVM Extension Pack (0.0.1) installed.

I run VS Code from Windows and connect to my WSL via SSH. GraalVM is installed within the Ubuntu WSL (GraalVM Version : EE 20.0.0).

An exception is generated when launching the app, as follows:

`node --jvm --polyglot --inspect server.js`

The app still runs and produces the output page, as expected. If I set a break point, the application halts and I go to VS Code, the app is being debugged, but it will halt at net.js, but not at my breakpoint. In fact although my breakpoint, which is in the main rendering code of server.js (part of the demo) the code never stops at my breakpoint.

The following exception is generated upon starting the application - which continues to run:

java.lang.Exception: Event onExecute failed for instrument class com.oracle.truffle.api.debug.impl.DebuggerInstrument and listener/factory com.oracle.truffle.api.debug. Breakpoint$1@4a717619. at com.oracle.truffle.api.instrumentation.ProbeNode.exceptionEventForClientInstrument(ProbeNode.java:617) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.notifySourceExecutedBinding(InstrumentationHandler.java:896) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.addSourceExecutionBinding(InstrumentationHandler.java:538) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.attachExecuteSourceListener(InstrumentationHandler.java:1045) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.access$2100(InstrumentationHandler.java:93) at com.oracle.truffle.api.instrumentation.InstrumentationHandler$AbstractInstrumenter.attachExecuteSourceListener(InstrumentationHandler.java:1950) at com.oracle.truffle.api.debug.Breakpoint.install(Breakpoint.java:548) at com.oracle.truffle.api.debug.Breakpoint.install(Breakpoint.java:537) at com.oracle.truffle.api.debug.DebuggerSession.install(DebuggerSession.java:768) at com.oracle.truffle.api.debug.DebuggerSession.install(DebuggerSession.java:750) at com.oracle.truffle.tools.chromeinspector.SuspendableLocationFinder.findSuspendableLocations(SuspendableLocationFinder.java:78) at com.oracle.truffle.tools.chromeinspector.InspectorDebugger.getPossibleBreakpoints(InspectorDebugger.java:286) at com.oracle.truffle.tools.chromeinspector.server.InspectServerSession.doProcessCommand(InspectServerSession.java:360) at com.oracle.truffle.tools.chromeinspector.server.InspectServerSession.processCommand(InspectServerSession.java:249) at com.oracle.truffle.tools.chromeinspector.server.InspectServerSession.access$300(InspectServerSession.java:61) at com.oracle.truffle.tools.chromeinspector.server.InspectServerSession$CommandProcessThread.run(InspectServerSession.java:600) Caused by: java.lang.ClassCastException: com.oracle.truffle.js.nodes.JavaScriptNodeWrapper cannot be cast to com.oracle.truffle.js.nodes.function.FunctionRootNode at com.oracle.truffle.js.nodes.function.FunctionBodyNode.materializeInstrumentableNodes(FunctionBodyNode.java:85) at com.oracle.truffle.api.instrumentation.InstrumentationHandler$AbstractNodeVisitor.materializeSyntaxNodes(InstrumentationHandler.java:1358) at com.oracle.truffle.api.instrumentation.InstrumentationHandler$AbstractNodeVisitor.visit(InstrumentationHandler.java:1317) at com.oracle.truffle.api.nodes.NodeUtil.forEachChild(NodeUtil.java:468) at com.oracle.truffle.api.instrumentation.InstrumentationHandler$AbstractNodeVisitor.visit(InstrumentationHandler.java:1342) at com.oracle.truffle.api.nodes.NodeUtil.forEachChild(NodeUtil.java:468) at com.oracle.truffle.api.instrumentation.InstrumentationHandler$AbstractNodeVisitor.visit(InstrumentationHandler.java:1342) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.visitRoot(InstrumentationHandler.java:1174) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.visitRoots(InstrumentationHandler.java:720) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.visitLoadedSourceSections(InstrumentationHandler.java:480) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.visitLoadedSourceSections(InstrumentationHandler.java:1041) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.access$2000(InstrumentationHandler.java:93) at com.oracle.truffle.api.instrumentation.InstrumentationHandler$AbstractInstrumenter.visitLoadedSourceSections(InstrumentationHandler.java:1944) at com.oracle.truffle.api.debug.SuspendableLocationFinder.findNearestBound(SuspendableLocationFinder.java:114) at com.oracle.truffle.api.debug.SuspendableLocationFinder.findNearest(SuspendableLocationFinder.java:92) at com.oracle.truffle.api.debug.BreakpointLocation$BreakpointSourceLocation.adjustLocation(BreakpointLocation.java:241) at com.oracle.truffle.api.debug.Breakpoint$1.onExecute(Breakpoint.java:555) at com.oracle.truffle.api.instrumentation.InstrumentationHandler.notifySourceExecutedBinding(InstrumentationHandler.java:891) ... 14 more

eleinadani commented 4 years ago

Thanks for the report. This was fixed in https://github.com/graalvm/graaljs/commit/cce6e3b14fb06f69ca3cdddab79ef36946a14e97