apache / apache/camel-quarkus

Intermittent native build failures due to java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread was found in the image heap

Open
#8,344 4 comments 0 reactions 0 assignees View on GitHub
area/native bug native
Dominant language
Java
Stars
302
Forks
232
Avg merge
1d 22h
Merged PRs (30d)
108

Description

### Bug description

Seen this native build failure a few times in different tests. Seems to be triggered from `Charset` but i am not sure from exactly where.

```
Fatal error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: An object of type 'java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.
This is not allowed for correctness reasons: All objects that are stored in the image heap must be initialized at build time.

You now have two options to resolve this:

1) If it is intended that objects of type 'java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread' are persisted in the image heap, add

'--initialize-at-build-time=java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread'

to the native-image arguments. Note that initializing new types can store additional objects to the heap. It is advised to check the static fields of 'java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread' to see if they are safe for build-time initialization, and that they do not contain any sensitive data that should not become part of the image.

2) If these objects should not be stored in the image heap, you can use

'--trace-object-instantiation=java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread'

to find classes that instantiate these objects. Once you found such a class, you can mark it explicitly for run time initialization with

'--initialize-at-run-time='

to prevent the instantiation of the object.

If you are seeing this message after upgrading to a new GraalVM release, this means that some objects ended up in the image heap without their type being marked with --initialize-at-build-time.
To fix this, include '--initialize-at-build-time=java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread' in your configuration. If the classes do not originate from your code, it is advised to update all library or framework dependencies to the latest version before addressing this error.

The following detailed trace displays from which field in the code the object was reached.
Object was reached by
reading field jdk.internal.misc.ThreadTracker$ThreadRef.thread of constant
jdk.internal.misc.ThreadTracker$ThreadRef@6e67dec4: ThreadRef[thread=Thread[#23,ForkJoinPool.commonPool-worker-1,5,InnocuousForkJoin...
reading field java.util.concurrent.ConcurrentHashMap$Node.key of constant
java.util.concurrent.ConcurrentHashMap$Node@6273c268: ThreadRef[thread=Thread[#23,ForkJoinPool.commonPool-worker-1,5,InnocuousForkJoin...
indexing into array java.util.concurrent.ConcurrentHashMap$Node[]@380e2d10: [Ljava.util.concurrent.ConcurrentHashMap$Node;@380e2d10 at index 7
reading field java.util.concurrent.ConcurrentHashMap.table of constant
java.util.concurrent.ConcurrentHashMap@42533963: {ThreadRef[thread=Thread[#23,ForkJoinPool.commonPool-worker-1,5,InnocuousForkJoi...
reading field java.util.concurrent.ConcurrentHashMap$CollectionView.map of constant
java.util.concurrent.ConcurrentHashMap$KeySetView@2c13fe6e: [ThreadRef[thread=Thread[#23,ForkJoinPool.commonPool-worker-1,5,InnocuousForkJoi...
reading field jdk.internal.misc.ThreadTracker.threads of constant
jdk.internal.misc.ThreadTracker@5ffaffc2: jdk.internal.misc.ThreadTracker@5ffaffc2
scanning root jdk.internal.misc.ThreadTracker@5ffaffc2: jdk.internal.misc.ThreadTracker@5ffaffc2 embedded in
java.nio.charset.Charset.tryBeginLookup(Charset.java:389)
parsing method java.nio.charset.Charset.tryBeginLookup(Charset.java:389) reachable via the parsing context
at static root method.(Unknown Source)

at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onObjectReachable(ImageHeapScanner.java:618)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.heap.SVMImageHeapScanner.onObjectReachable(SVMImageHeapScanner.java:127)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$markReachable$0(ImageHeapScanner.java:589)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:166)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:152)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1750)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1742)
at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1659)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:511)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1450)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2019)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the native-image build failures and inspect java.nio.charset.Charset.tryBeginLookup at Charset.java:389, following the reported object-reachability trace. Reproduce the failure across the affected tests and use --trace-object-instantiation for the reported thread type; done means identifying the triggering class and establishing a correct, reproducible initialization configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.