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

[native-image] Problems during compilation of http4s with http client #388

Closed
lbialy opened this issue Apr 30, 2018 · 5 comments
Closed
Assignees

Comments

@lbialy
Copy link

lbialy commented Apr 30, 2018

I was trying to compile my POC service and got this:

    analysis:  14,013.19 ms
error: Must not have a started Thread in the image heap.
Detailed message:
Error: Must not have a started Thread in the image heap.
Trace:  object org.http4s.blaze.util.TickWheelExecutor
        object org.http4s.client.blaze.bits$
        field org.http4s.client.blaze.bits$.MODULE$

Error: Processing image build request failed

How to reproduce -

  1. pull https://github.com/lbialy/blockchain-explorer-on-cats
  2. run sbt assembly
  3. run native-image -H:+ReportUnsupportedElementsAtRuntime -jar blockchain-explorer-on-cats-assembly-0.0.1-SNAPSHOT.jar
@lbialy
Copy link
Author

lbialy commented Apr 30, 2018

What does this Must not have a started Thread in the image heap. error mean?

@cstancu
Copy link
Member

cstancu commented Apr 30, 2018

That error means that you start a thread in a static initializer. This is not allowed. The error message has been improved since the release.

@thomaswue
Copy link
Member

One way to solve these issues could be to run specific static initializers not at boot image generation time, but make them part of the native image.

@cstancu cstancu self-assigned this Apr 30, 2018
@lbialy
Copy link
Author

lbialy commented May 1, 2018

I was able to pinpoint the problem in http4s' blaze-based client here:
https://github.com/http4s/http4s/blob/b9a28ddcd335cf5dee60a9f7d3be5bdc12523179/blaze-client/src/main/scala/org/http4s/client/blaze/bits.scala#L20
changing that val to lazy val seems not to break anything and makes native compilation possible again.

I think we can close this issue. Is this limitation in documentation somewhere? I guess it's quite important.

@cstancu
Copy link
Member

cstancu commented May 1, 2018

@lbialy This limitation is not explicitly in the documentation. I'll fix it.
@thomaswue that should be possible, however it requires more investigation. If we push some initializer to runtime we need to push all other initializers that might depend on it and need to be careful about the initialization order.

@cstancu cstancu closed this as completed May 1, 2018
zakkak added a commit to zakkak/mandrel that referenced this issue Jun 16, 2022
zakkak added a commit to zakkak/mandrel that referenced this issue Jun 16, 2022
quarkusio/quarkus#25986 allows Quarkus native to
work with the image-builder running on module path.

Reverts: oracle#388, oracle#390, oracle#391

Closes: oracle#389
zakkak added a commit to zakkak/mandrel that referenced this issue Jun 20, 2022
quarkusio/quarkus#25986 allows Quarkus native to
work with the image-builder running on module path.

Reverts: oracle#388, oracle#390, oracle#391

Closes: oracle#389
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

3 participants