Skip to content

Support Sandbox MaxCPUTime & MaxHeapMemory while using virtual threads #11058

Open
@AhmedAbdelfaheem

Description

@AhmedAbdelfaheem

Describe GraalVM and your environment :

  • GraalVM version or commit id if built from source: 24.0
  • CE or EE: EE
  • JDK version: 21+
  • OS and OS Version: macOS Catalina
  • Architecture: [macOS]
  • The output of java -Xinternalversion:
ThreadMXBean.getThreadCpuTime() is not supported or enabled by the host VM but required for CPU time limit.

Have you verified this issue still happens when using the latest snapshot?
yes

Describe the issue
when i enable the virtual threads in my spring boot app while using the sandbox options MaxCPUTime & MaxHeapMemory i get the ThreadMXBean.getThreadCpuTime() is not supported or enabled by the host VM but required for CPU time limit.

Code snippet or code repository that reproduces the issue

 private Context buildGraalVMContext() {
        return Context
                .newBuilder(LANGUAGES)
                .allowExperimentalOptions(true)
                .allowAllAccess(true)
                .option("js.esm-eval-returns-exports", "true")
                .option("sandbox.MaxCPUTime", "%ds".formatted(timeoutSeconds))
                .option("sandbox.MaxHeapMemory", scriptMaxHeapSize)
                .allowIO(IOAccess.newBuilder()
                        .fileSystem(libraryFileSystem).build())
                .engine(engine).build();
    }

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. Step one add the options MaxCPUTime & MaxHeapMemory when setup the graalvm context

Expected behavior
I expect to the context to get created and the eval run seamlessly

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions