graalvm

Bruno do Nascimento Maciel 2024-12-18T21:26:31.594809Z

Hey folks, I trying to generate a native image for a telegram bot that uses morse (https://github.com/Otann/morse) 🧵

Bruno do Nascimento Maciel 2024-12-18T21:28:52.661269Z

While build the native image I am getting this error related to a Thread being started:

Fatal error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected a started Thread in the image heap. Thread name: clojure.core.async.timers/timeout-daemon. Threads running in the image generator are no longer running at image runtime. Prevent threads from starting during image generation, or a started thread from being included in the image.

Bruno do Nascimento Maciel 2024-12-18T21:31:12.406669Z

Here is the complete output: https://gist.github.com/macielti/e4f37ea45c7bda493e8cc565f04f82ca

Bruno do Nascimento Maciel 2024-12-18T21:35:37.929589Z

I know that this is related to this code: https://github.com/clojure/core.async/blob/f0cb33ca0fbc5b63614eedde7c3ac026675af70e/src/main/clojure/clojure/core/async/impl/timers.clj#L53

Bruno do Nascimento Maciel 2024-12-18T21:36:58.663289Z

but I don't have enough knowledge to circumvent that

borkdude 2024-12-18T21:41:04.019149Z

that code is ok, but it's not ok to deref that thing on the top level

borkdude 2024-12-18T21:45:00.783099Z

you could try to compile an example program that has less code and add stuff until it fails, this should give you a clearer picture of what code triggers this

Bruno do Nascimento Maciel 2024-12-18T21:46:09.415679Z

At the top level it is in this line (p/start token bot-api) . I think that I will have to go deep on the library implementation

borkdude 2024-12-18T21:46:40.028819Z

where is that line, in your project?

Bruno do Nascimento Maciel 2024-12-18T21:50:13.519699Z

it is in a branch from the forked repository graalvm-clojure https://github.com/macielti/graalvm-clojure/blob/add-morse/morse/src/simple/main.clj#L29

Bruno do Nascimento Maciel 2024-12-18T21:50:44.722699Z

I created a draft pull request https://github.com/clj-easy/graalvm-clojure/pull/68

Bruno do Nascimento Maciel 2024-12-18T21:53:40.601579Z

I event tried to use a when to only call the (p/start token bot-api) when the start argument is provided via command line to avoid this being interpreted at the build time. But it did not worked, I am not sure if GraalVM works this way

borkdude 2024-12-18T21:54:02.368409Z

it's late here but I might check tomorrow time willing

Bruno do Nascimento Maciel 2024-12-18T21:55:30.071949Z

nice, I really appreciate your willingness to help. I will wait.

Nikolai Tatarinov 2025-04-15T11:08:31.041809Z

@brunodonascimentomaci have you figured out this issue in the end? I'm trying to build a native image with morse, and running into the same issue.