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 native image compatibility #81

Open
donbeave opened this issue Nov 13, 2021 · 2 comments
Open

GraalVM native image compatibility #81

donbeave opened this issue Nov 13, 2021 · 2 comments

Comments

@donbeave
Copy link

Hello!

Thank you for such an amazing library, I'm using it for some Micronaut projects.

I found that this library is not supporting the GraalVM native image feature, I have tried to build an application with logback-appender-nodep and it failed with an exception:

Error: Detected a direct/mapped ByteBuffer in the image heap. A direct ByteBuffer has a pointer to unmanaged C memory, and C memory from the image generator is not available at image runtime.A mapped ByteBuffer references a file descriptor, which is no longer open and mapped at run time.   To see how this object got instantiated use --trace-object-instantiation=java.nio.DirectByteBuffer. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
[application:38538]    Detailed message:
  [total]:  96,274.29 ms, Trace: Object was reached by
 7.97 GB
        reading field pl.tkowalcz.tjahzi.org.agrona.concurrent.UnsafeBuffer.byteBuffer of
                constant pl.tkowalcz.tjahzi.org.agrona.concurrent.UnsafeBuffer@f8a283 reached by
        reading field pl.tkowalcz.tjahzi.LogBufferSerializer.buffer of
                constant pl.tkowalcz.tjahzi.LogBufferSerializer@6740bb47 reached by
        reading field pl.tkowalcz.tjahzi.TjahziLogger.serializer of
                constant pl.tkowalcz.tjahzi.TjahziLogger@4da08d11 reached by
        reading field pl.tkowalcz.tjahzi.logback.LokiAppender.logger of
                constant pl.tkowalcz.tjahzi.logback.LokiAppender@1c61966b reached by
        indexing into array
                constant java.lang.Object[]@2da676b6 reached by
        reading field java.util.concurrent.CopyOnWriteArrayList.array of
                constant java.util.concurrent.CopyOnWriteArrayList@7516bfd8 reached by
        reading field ch.qos.logback.core.util.COWArrayList.underlyingList of
                constant ch.qos.logback.core.util.COWArrayList@4aa193f reached by
        reading field ch.qos.logback.core.spi.AppenderAttachableImpl.appenderList of
                constant ch.qos.logback.core.spi.AppenderAttachableImpl@7a6d3c78 reached by
        reading field ch.qos.logback.classic.Logger.aai of
                constant ch.qos.logback.classic.Logger@3a065022 reached by
        reading field ch.qos.logback.classic.LoggerContext.root of
                constant ch.qos.logback.classic.LoggerContext@61d7f698 reached by
        reading field ch.qos.logback.classic.Logger.loggerContext of
                constant ch.qos.logback.classic.Logger@658579fb reached by
        scanning method io.micronaut.runtime.Micronaut.lambda$null$0(Micronaut.java:111)
Call path from entry point to io.micronaut.runtime.Micronaut.lambda$null$0(EmbeddedApplication, CountDownLatch, boolean, Thread):
        at io.micronaut.runtime.Micronaut.lambda$null$0(Micronaut.java:111)
        at io.micronaut.runtime.Micronaut$$Lambda$1044/0x00000007c26c8b08.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:833)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
        at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

Do you have any plans to add support for GraalVM?

If you need, I can provide a sample app to reproduce this error.

@tkowalcz
Copy link
Owner

tkowalcz commented Nov 14, 2021

Hi,

glad you find it useful! I will happily make changes to make the native image happy. I tried to create a project that builds native image and encountered several errors but not that one yet.

In principle it is complaining about log buffer component that has a buffer object that was allocated off heap. There is the configuration option UseOffHeapBuffer that you can set to false, maybe that will fix it?

@tkowalcz
Copy link
Owner

That being said - I will appreciate if you can send me that sample app so I can confirm it helps or develop a real fix.

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

No branches or pull requests

2 participants