question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

native-image compilation of epoll transport fails

See original GitHub issue

Expected behavior

My small repro compiles as a native image and works as expected if I use Nio* family of transports. My expectation was that switching to epoll transport would similarly work.

Actual behavior

If I switch to epoll (linux-x86_64) I get a compilation error:

Error: Classes that should be initialized at run time got initialized during image building:
 io.netty.util.AbstractReferenceCounted the class was requested to be initialized at build time (from the command line). io.netty.util.AbstractReferenceCounted has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.util.AbstractReferenceCounted

com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 io.netty.util.AbstractReferenceCounted the class was requested to be initialized at build time (from the command line). io.netty.util.AbstractReferenceCounted has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of io.netty.util.AbstractReferenceCounted

	at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
	at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:510)
	at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:187)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:710)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:710)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

Minimal yet complete reproducer code (or URL to code)

Here’s a repro: https://github.com/perezd/netty-epoll-native-repro

w/ Bazel 3.5.0 installed, run this command from the root of the project:

bazel run :main-native

Netty version

4.1.52.Final (linux-x86_64)

JVM version (e.g. java -version)

java -version openjdk version “11.0.8” 2020-07-14 OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04) OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

OS version (e.g. uname -a)

Linux desktop 5.4.0-48-generic #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I’ve searched around and attempted various workarounds but nothing seems to work.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
jameswardcommented, Dec 18, 2021

I also ran into this again with Netty 4.1.70 and GraalVM 21.3.0 but was able to get it working with:

  --initialize-at-run-time=io.netty.channel.DefaultFileRegion
  --initialize-at-run-time=io.netty.channel.epoll.Native
  --initialize-at-run-time=io.netty.channel.epoll.Epoll
  --initialize-at-run-time=io.netty.channel.epoll.EpollEventLoop
  --initialize-at-run-time=io.netty.channel.epoll.EpollEventArray
  --initialize-at-run-time=io.netty.channel.kqueue.KQueue
  --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventLoop
  --initialize-at-run-time=io.netty.channel.kqueue.KQueueEventArray
  --initialize-at-run-time=io.netty.channel.kqueue.Native
  --initialize-at-run-time=io.netty.channel.unix.Limits
  --initialize-at-run-time=io.netty.channel.unix.Errors
  --initialize-at-run-time=io.netty.channel.unix.IovArray
0reactions
jacekgajekcommented, Dec 15, 2021

Hello, I try to build a native image of a Micronaut service and have lots of similar errors

(Error: Classes that should be initialized at run time got initialized during image building: io.grpc.netty.shaded.io.netty.buffer.ByteBufUtil the class was requested to be initialized at run time (from jar:file:///home/jacek/.gradle/caches/modules-2/files-2.1/io.grpc/grpc-netty-shaded/1.41.0/43fee785c101b3bfa3f7d916d8b47d5d736cbff2/grpc-netty-shaded-1.41.0.jar!/META-INF/native-image/io.grpc.netty.shaded.io.netty/buffer/native-image.properties with ‘io.grpc.netty.shaded.io.netty.buffer.ByteBufUtil’). To see why io.grpc.netty.shaded.io.netty.buffer.ByteBufUtil got initialized use --trace-class-initialization=io.grpc.netty.shaded.io.netty.buffer.ByteBufUtil io.grpc.netty.shaded.io.netty.buffer.ByteBufAllocator the class was requested to be initialized at run time (from jar:file:///home/jacek/.gradle/caches/modules-2/files-2.1/io.grpc/grpc-netty-shaded/1.41.0/43fee785c101b3bfa3f7d916d8b47d5d736cbff2/grpc-netty-shaded-1.41.0.jar!/META-INF/native-image/io.grpc.netty.shaded.io.netty/buffer/native-image.properties with ‘io.grpc.netty.shaded.io.netty.buffer.ByteBufAllocator’). To see why io.grpc.netty.shaded.io.netty.buffer.ByteBufAllocator got initialized use --trace-class-initialization=io.grpc.netty.shaded.io.netty.buffer.ByteBufAllocator …

Is there a known solution or a workaround for this? From various suggestions I tried

  buildArgs.add(
        "--initialize-at-run-time=" +
         "io.grpc.netty.shaded.io.netty.util.internal.logging.Log4JLogger," +
            "io.grpc.netty.shaded.io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator," +
            "io.netty.handler.ssl.util.ThreadLocalInsecureRandom," +
            "io.netty.channel.unix,io.netty.channel.epoll,io.netty.channel.kqueue"
)

but it didn’t help. Is there some radical workaround which maybe sacrifice performance but at least allow to successfully compile?

Read more comments on GitHub >

github_iconTop Results From Across the Web

graalvm/native-image - Gitter
I'm currently testing native image generation with epoll and ssl support. So far the image is building just fine. (with jni epoll support)....
Read more >
Building a Vert.x Native Image
If you build the image this will compile, but won't work at runtime. One thing is needed: Enable the security features to be...
Read more >
What have caused the problem of "Could not find netty ...
Strangely, the jar in question "netty-transport-native-epoll-4.1.76.Final-linux-x86_64" can't be found on my computer either. The name appears ...
Read more >
Native Reference Guide - Quarkus
Up to version 2.13, Quarkus used the “space/time” GC collection policy by ... the native executable by adding additional native-image build options using ......
Read more >
netty-parent : 4.1.58.Final - Maven Central Repository Search
Detect if we use GraalVM and if so enable the native image testsuite ... <module>transport-native-epoll</module> ... Enforce JDK 1.8+ for compilation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found