Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graalvm Isolate thread not being killed when related Java threads spawned in Context are alive #2617

Closed
AndreiYu opened this issue Jun 26, 2020 · 3 comments
Assignees

Comments

@AndreiYu
Copy link

AndreiYu commented Jun 26, 2020

Describe the issue
Isolate thread can't be stopped with Isolates.tearDownIsolate(isolateThread) when isolateThread has child Java threads (created from inside Context) alive.

Steps to reproduce the issue

  1. Create a JavaScript function that calls some long-running Java code (heavy computation or http-request that keeps connection alive)
  2. Create Isolate thread, that creates JavaScript context and evaluates this JS function
  3. Set timeout for execution and call context.close(true) from a new thread when the time finishes.
  4. Perform Isolates.tearDownIsolate(isolateThread);

Expected result
IsolateThread and all related resources are discarded after timeout. Related heavy Java computation task is stopped.

Actual result
IsolateThread can't be teared down till Java - related task is finished.

Describe GraalVM and your environment:

  • GraalVM version : GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
  • JDK major version: openjdk 11.0.7 2020-04-14
  • OS: MacOS Catalina 10.15.5 (19F101)
  • Architecture: 19.5.0 Darwin Kernel Version 19.5.0; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

More details
Consider adding the --native-image-info and --verbose flags when building your native image and paste output below.

ayushkevich@Andreis-MBP getting-started 3 % ./mvnw package -Dquarkus.package.type=native -Dquarkus.native.additional-build-args=--language:js,--native-image-info,--verbose,-H:IncludeResources='..js',-H:+StackTrace
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.acme:getting-started:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-compiler-plugin @ line 77, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ----------------------< org.acme:getting-started >----------------------
[INFO] Building getting-started 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ getting-started ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ getting-started ---
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ getting-started ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ getting-started ---
[INFO] Building jar: /Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- quarkus-maven-plugin:1.5.1.Final:build (default) @ getting-started ---
[INFO] [org.jboss.threads] JBoss Threads version 3.1.1.Final
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/getting-started-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/getting-started-1.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.1.0 (Java Version 11.0.7)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] /Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/bin/native-image -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Duser.language=en -J-Dfile.encoding=UTF-8 --language:js --native-image-info --verbose -H:IncludeResources=.
.js -H:+StackTrace --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -H:+JNI -jar getting-started-1.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:-IncludeAllTimeZones -H:EnableURLProtocols=http --no-server -H:-UseServiceLoaderFeature -H:+StackTrace getting-started-1.0-SNAPSHOT-runner
Apply jar:file:///Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started%203/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.graalvm.sdk.graal-sdk-19.3.1.jar!/META-INF/native-image/org.graalvm.polyglot/native-image.properties
Apply jar:file:///Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started%203/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-handler-4.1.49.Final.jar!/META-INF/native-image/io.netty/handler/native-image.properties
Apply jar:file:///Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started%203/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-common-4.1.49.Final.jar!/META-INF/native-image/io.netty/common/native-image.properties
Apply jar:file:///Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started%203/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.49.Final.jar!/META-INF/native-image/io.netty/buffer/native-image.properties
Apply jar:file:///Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started%203/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-transport-4.1.49.Final.jar!/META-INF/native-image/io.netty/transport/native-image.properties
Apply jar:file:///Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started%203/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-http-4.1.49.Final.jar!/META-INF/native-image/io.netty/codec-http/native-image.properties
Apply jar:file:///Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started%203/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-http2-4.1.49.Final.jar!/META-INF/native-image/io.netty/codec-http2/native-image.properties
Executing [
/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/bin/java
-XX:+UseParallelGC
-XX:+UnlockExperimentalVMOptions
-XX:+EnableJVMCI
-Dtruffle.TrustAllTruffleRuntimeProviders=true
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime
-Dgraalvm.ForcePolyglotInvalid=true
-Dgraalvm.locatorDisabled=true
-Dsubstratevm.IgnoreGraalVersionCheck=true
-Djava.lang.invoke.stringConcat=BC_SB
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED
--add-exports
jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED
--add-opens
jdk.internal.vm.compiler/org.graalvm.compiler.debug=ALL-UNNAMED
--add-opens
jdk.internal.vm.compiler/org.graalvm.compiler.nodes=ALL-UNNAMED
--add-opens
jdk.unsupported/sun.reflect=ALL-UNNAMED
--add-opens
java.base/jdk.internal.module=ALL-UNNAMED
--add-opens
java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens
java.base/jdk.internal.reflect=ALL-UNNAMED
--add-opens
java.base/java.io=ALL-UNNAMED
--add-opens
java.base/java.lang=ALL-UNNAMED
--add-opens
java.base/java.lang.reflect=ALL-UNNAMED
--add-opens
java.base/java.lang.invoke=ALL-UNNAMED
--add-opens
java.base/java.lang.ref=ALL-UNNAMED
--add-opens
java.base/java.net=ALL-UNNAMED
--add-opens
java.base/java.nio=ALL-UNNAMED
--add-opens
java.base/java.nio.file=ALL-UNNAMED
--add-opens
java.base/java.security=ALL-UNNAMED
--add-opens
java.base/javax.crypto=ALL-UNNAMED
--add-opens
java.base/java.util=ALL-UNNAMED
--add-opens
java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens
java.base/sun.security.x509=ALL-UNNAMED
--add-opens
java.base/jdk.internal.logger=ALL-UNNAMED
--add-opens
org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED
--add-opens
org.graalvm.sdk/org.graalvm.polyglot=ALL-UNNAMED
--add-opens
org.graalvm.truffle/com.oracle.truffle.polyglot=ALL-UNNAMED
--add-opens
org.graalvm.truffle/com.oracle.truffle.api.impl=ALL-UNNAMED
-XX:+UseJVMCINativeLibrary
-Xss10m
-Xms1g
-Duser.country=US
-Duser.language=en
-Djava.awt.headless=true
-Dorg.graalvm.version=20.1.0
-Dorg.graalvm.config=
-Dcom.oracle.graalvm.isaot=true
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader
-Xshare:off
--module-path
/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/truffle/truffle-api.jar
-Dtruffle.TruffleRuntime=com.oracle.svm.truffle.api.SubstrateTruffleRuntime
-Dgraalvm.ForcePolyglotInvalid=false
-Dpolyglot.image-build-time.PreinitializeContexts=js
-Xmx13743895344
-javaagent:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/svm.jar
-Djdk.internal.lambda.disableEagerInitialization=true
-Djdk.internal.lambda.eagerlyInitialize=false
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false
-Dsun.nio.ch.maxUpdateArraySize=100
-Djava.util.logging.manager=org.jboss.logmanager.LogManager
-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory
-Dvertx.disableDnsResolver=true
-Dio.netty.leakDetection.level=DISABLED
-Dio.netty.allocator.maxOrder=1
-Duser.language=en
-Dfile.encoding=UTF-8
-cp
/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/llvm-wrapper-shadowed.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/svm.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/objectfile.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/llvm-platform-specific-shadowed.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/javacpp-shadowed.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/svm-llvm.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/pointsto.jar
'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus'
-imagecp
'/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/llvm-wrapper-shadowed.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/svm.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/objectfile.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/llvm-platform-specific-shadowed.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/javacpp-shadowed.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/svm-llvm.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/builder/pointsto.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/library-support.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/regex/tregex.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/icu4j.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/asm-util-7.1.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/graaljs.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/asm-7.1.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/asm-commons-7.1.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/trufflenode.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/asm-tree-7.1.jar:/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/languages/js/asm-analysis-7.1.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/jakarta.annotation.jakarta.annotation-api-1.3.5.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/jakarta.inject.jakarta.inject-api-1.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.smallrye.config.smallrye-config-common-1.7.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.smallrye.config.smallrye-config-1.7.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.logging.jboss-logging-3.3.2.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.logmanager.jboss-logmanager-embedded-1.0.4.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.logging.jboss-logging-annotations-2.1.0.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.threads.jboss-threads-3.1.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.slf4j.slf4j-api-1.7.30.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.slf4j.slf4j-jboss-logging-1.2.0.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.graalvm.sdk.graal-sdk-19.3.1.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.wildfly.common.wildfly-common-1.5.4.Final-format-001.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-bootstrap-runner-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-core-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-development-mode-spi-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.reactivestreams.reactive-streams-1.0.3.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.smallrye.reactive.mutiny-0.5.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.security.quarkus-security-1.1.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/jakarta.el.jakarta.el-api-3.0.3.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/jakarta.interceptor.jakarta.interceptor-api-1.2.5.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/jakarta.enterprise.jakarta.enterprise.cdi-api-2.0.2.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-handler-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-netty-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-common-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-transport-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-socks-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-handler-proxy-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-http-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-http2-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-resolver-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-codec-dns-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-resolver-dns-4.1.49.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/com.fasterxml.jackson.core.jackson-core-2.10.4.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.vertx.vertx-core-3.9.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-vertx-core-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.vertx.vertx-web-common-3.9.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.vertx.vertx-auth-common-3.9.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.vertx.vertx-bridge-common-3.9.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.vertx.vertx-web-3.9.0.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-vertx-http-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/jakarta.transaction.jakarta.transaction-api-1.3.3.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.arc.arc-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.eclipse.microprofile.context-propagation.microprofile-context-propagation-api-1.0.1.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-arc-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.spec.javax.ws.rs.jboss-jaxrs-api_2.1_spec-2.0.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.spec.javax.xml.bind.jboss-jaxb-api_2.3_spec-2.0.0.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.resteasy.resteasy-core-spi-4.5.3.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.eclipse.microprofile.config.microprofile-config-api-1.4.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/org.jboss.resteasy.resteasy-core-4.5.3.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/com.sun.activation.jakarta.activation-1.2.1.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-resteasy-common-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/jakarta.validation.jakarta.validation-api-2.0.2.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-resteasy-server-common-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/lib/io.quarkus.quarkus-resteasy-1.5.1.Final.jar:/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar/getting-started-1.0-SNAPSHOT-runner.jar'
'-H:Path=/Users/ayushkevich/Documents/Projects/quarkus-quickstarts/getting-started 3/target/getting-started-1.0-SNAPSHOT-native-image-source-jar'
-H:Features=com.oracle.svm.truffle.TruffleFeature,org.graalvm.home.HomeFinderFeature
-H:MaxRuntimeCompileMethods=1400
-H:ClassInitialization=org.graalvm.launcher:build_time,com.oracle.truffle:build_time
-H:MaxRuntimeCompileMethods=9000
-H:ClassInitialization=com.oracle.truffle.js:build_time,com.oracle.js.parser:build_time,com.oracle.truffle.trufflenode:build_time,com.oracle.truffle.regex:build_time
-H:ClassInitialization=com.ibm.icu:run_time
-H:ReflectionConfigurationResources=com/oracle/truffle/js/runtime/resources/reflect-config.json
-H:ResourceConfigurationResources=com/oracle/truffle/js/runtime/resources/resource-config.json
-H:+DumpTargetInfo
'-H:IncludeResources=.*.js'
-H:ClassInitialization=:build_time
'-H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime'
-H:+JNI
-H:Class=io.quarkus.runner.GeneratedMain
-H:ClassInitialization=org.graalvm.polyglot:build_time
-H:ClassInitialization=io.netty.handler.ssl.util.ThreadLocalInsecureRandom:run_time
-H:ClassInitialization=io.netty.util.AbstractReferenceCounted:run_time,io.netty.util.concurrent.GlobalEventExecutor:run_time,io.netty.util.concurrent.ImmediateEventExecutor:run_time,io.netty.util.concurrent.ScheduledFutureTask:run_time,io.netty.util.internal.ThreadLocalRandom:run_time
-H:ClassInitialization=io.netty.buffer.PooledByteBufAllocator:run_time,io.netty.buffer.ByteBufAllocator:run_time,io.netty.buffer.ByteBufUtil:run_time,io.netty.buffer.AbstractReferenceCountedByteBuf:run_time
-H:ReflectionConfigurationResources=META-INF/native-image/io.netty/transport/reflection-config.json
-H:ClassInitialization=io.netty.handler.codec.http.HttpObjectEncoder:run_time,io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder:run_time,io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder:run_time
-H:ClassInitialization=io.netty:build_time
-H:ClassInitialization=io.netty.handler.codec.http2.Http2CodecUtil:run_time,io.netty.handler.codec.http2.Http2ClientUpgradeCodec:run_time,io.netty.handler.codec.http2.Http2ConnectionHandler:run_time,io.netty.handler.codec.http2.DefaultHttp2FrameWriter:run_time
-H:+ReportExceptionStackTraces
-H:-AddAllCharsets
-H:-IncludeAllTimeZones
-H:EnableURLProtocols=http
-H:-UseServiceLoaderFeature
-H:+StackTrace
-H:FallbackThreshold=0
-H:CLibraryPath=/Users/ayushkevich/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/darwin-amd64
-H:Name=getting-started-1.0-SNAPSHOT-runner
]
-H:IncludeAllTimeZones and -H:IncludeTimeZones are now deprecated. Native-image includes all timezonesby default.
[getting-started-1.0-SNAPSHOT-runner:5049] classlist: 5,704.33 ms, 0.96 GB
[getting-started-1.0-SNAPSHOT-runner:5049] (cap): 3,756.26 ms, 0.96 GB
[getting-started-1.0-SNAPSHOT-runner:5049] setup: 5,314.83 ms, 0.96 GB
Building image for target platform: org.graalvm.nativeimage.Platform$DARWIN_AMD64
Using native toolchain:
Name: LLVM (clang)
Vendor: apple
Version: 11.0.3
Target architecture: x86_64
Path: /usr/bin/cc
Using CLibrary: com.oracle.svm.core.c.libc.GLibc
14:06:02,400 INFO [org.jbo.threads] JBoss Threads version 3.1.1.Final
[getting-started-1.0-SNAPSHOT-runner:5049] (clinit): 1,594.79 ms, 5.59 GB
Static libraries:
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/darwin-amd64/liblibchelper.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libnet.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/darwin-amd64/libstrictmath.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/darwin-amd64/libffi.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/darwin-amd64/libdarwin.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libextnet.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libnio.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libjava.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/darwin-amd64/libjvm.a
../../../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libzip.a
Other libraries: -framework CoreServices,pthread,-framework Foundation,dl,z
[getting-started-1.0-SNAPSHOT-runner:5049] (typeflow): 29,097.49 ms, 5.59 GB
[getting-started-1.0-SNAPSHOT-runner:5049] (objects): 28,086.85 ms, 5.59 GB
[getting-started-1.0-SNAPSHOT-runner:5049] (features): 5,205.26 ms, 5.59 GB
[getting-started-1.0-SNAPSHOT-runner:5049] analysis: 67,650.60 ms, 5.59 GB
[getting-started-1.0-SNAPSHOT-runner:5049] universe: 1,817.88 ms, 5.59 GB
9448 method(s) included for runtime compilation
[getting-started-1.0-SNAPSHOT-runner:5049] (parse): 5,348.31 ms, 5.65 GB
[getting-started-1.0-SNAPSHOT-runner:5049] (inline): 9,437.98 ms, 5.87 GB
[getting-started-1.0-SNAPSHOT-runner:5049] (compile): 32,062.27 ms, 6.33 GB
[getting-started-1.0-SNAPSHOT-runner:5049] compile: 50,963.07 ms, 6.33 GB
[getting-started-1.0-SNAPSHOT-runner:5049] image: 12,633.65 ms, 6.38 GB
[getting-started-1.0-SNAPSHOT-runner:5049] write: 2,495.58 ms, 6.38 GB
[getting-started-1.0-SNAPSHOT-runner:5049] [total]: 148,500.98 ms, 6.38 GB
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 151690ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:35 min
[INFO] Finished at: 2020-06-26T14:07:49+03:00
[INFO] ------------------------------------------------------------------------

Note: IF we try to execute pure JS endless function (for ex. while(true)) (without calling endless Java job from inside JavaScript), IsolateThread can be killed with Isolates.tearDownIsolate(isolateThread); as expected

Seems that the same issue has already been reported here: graalvm/graalvm-demos#33

Here is some test code to have a look closer look graalvm_native_isolates_issue

Thank you.

@AndreiYu AndreiYu changed the title Graalvm Isolate thread not being killed when related threads spawned in Context are alive Graalvm Isolate thread not being killed when related Java threads spawned in Context are alive Jun 26, 2020
@peter-hofer
Copy link
Member

Thank you @AndreiYu for your report. Calling tearDownIsolate uses a cooperative approach: it calls Thread.interrupt on each live thread, then wait until the threads have exited. It's the responsibility of the code running in the threads to handle the interrupt accordingly. Forcibly terminating threads is generally undesirable because it likely leads to resource leakages.
@woess @chumer what's the expected behavior of a Truffle execution in this scenario?

@AndreiYu
Copy link
Author

AndreiYu commented Jul 2, 2020

it calls Thread.interrupt on each live thread, then wait until the threads have exited. It's the responsibility of the code running in the threads to handle the interrupt accordingly. Forcibly terminating threads is generally undesirable because it likely leads to resource leakages.

Peter, Thank you for the clarification, is it possible, for ex. to allow forcibly terminate such threads inside tearDownIsolate if they were created as daemons? I tried this option as well, but daemon threads seem to behave just the same way as ordinary threads do. It could be a useful tool in hands of a developer since he could mark such Isolate-dependent thread as available to be forcibly killed and not put potential memory-leakage logic such as URL connection and IO write/read operations inside .

@peter-hofer
Copy link
Member

No, the problem with resource leakage is the same with daemon threads. Even when a programmer carefully avoids leakage of application resources, there are several internal mechanisms which could cause trouble here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants