Fork me on GitHub
#graalvm
<
2023-05-31
>
timo13:05:11

Hi, I am having a problem. I am trying to compile Datahike as a babashka-pod. Datahike is compiled as graalvm-bin everytime without problem. Now I added datahike as dep to a repo with my babashka-pod-code. But it fails with this error:

Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  To see
how this object got instantiated use --trace-object-instantiation=java.util.Random. 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.
Detailed message:
Trace: Object was reached by
  reading field taoensso.timbre$fn__17542$deterministic_rand__17543.rand of constant
    taoensso.timbre$fn__17542$deterministic_rand__17543@29cd7371: taoensso.timbre$fn__17542$deterministic_rand__17543@29cd7371
  reading field clojure.lang.Var.root of constant
    clojure.lang.Var@28d6e056: #'taoensso.timbre/deterministic-rand
  indexing into array java.lang.Object[]@1b4ee29b: [Ljava.lang.Object;@1b4ee29b
  reading field clojure.lang.PersistentHashMap$BitmapIndexedNode.array of constant
    clojure.lang.PersistentHashMap$BitmapIndexedNode@5841cbdf: clojure.lang.PersistentHashMap$BitmapIndexedNode@5841cbdf
  indexing into array clojure.lang.PersistentHashMap$INode[]@5148db66: [Lclojure.lang.PersistentHashMap$INode;@5148db66
  reading field clojure.lang.PersistentHashMap$ArrayNode.array of constant
    clojure.lang.PersistentHashMap$ArrayNode@3f8fa0b: clojure.lang.PersistentHashMap$ArrayNode@3f8fa0b
  indexing into array clojure.lang.PersistentHashMap$INode[]@34872ee8: [Lclojure.lang.PersistentHashMap$INode;@34872ee8
  reading field clojure.lang.PersistentHashMap$ArrayNode.array of constant
    clojure.lang.PersistentHashMap$ArrayNode@286ec6e2: clojure.lang.PersistentHashMap$ArrayNode@286ec6e2
  reading field clojure.lang.PersistentHashMap.root of constant
    clojure.lang.PersistentHashMap@5940e049: {default-output-msg-fn #'taoensso.timbre/default-output-msg-fn, get-rate-limiter...
  reading field java.util.concurrent.atomic.AtomicReference.value of constant
    java.util.concurrent.atomic.AtomicReference@43207ef8: {default-output-msg-fn #'taoensso.timbre/default-output-msg-fn, get-rate-limiter...
  reading field clojure.lang.Namespace.mappings of constant
    clojure.lang.Namespace@6acabec7: taoensso.timbre
  reading field clojure.lang.Var.ns of constant
    clojure.lang.Var@7b824581: #'taoensso.timbre/default-timestamp-opts
  scanning root clojure.lang.Var@7b824581: #'taoensso.timbre/default-timestamp-opts embedded in
    taoensso.timbre$_log_BANG_$fn__17518.invoke(timbre.cljc:665)
I don't use timbre in my pod-code, why does it fail now? Any idea?

borkdude13:05:48

I think this might be fixed with a newer version of timbre

borkdude13:05:00

Somewhere you or a dependency must be using timbre else you wouldn't get this error :)

timo13:05:33

datahike does use timbre but why is it not showing up when compiling datahike?

borkdude13:05:20

maybe a version difference

👍 4
timo13:05:11

works now 👍

igrishaev15:05:20

Let me ask more on this. What if I had a 3rd-party Java library which spawns an instance of Random in a class? Obviously I cannot fix their code.

igrishaev15:05:50

Asking because some time ago I had this with the official DynamoDB SDK. I wrote my own client in pure HTTP but anyway I'd like to know how to solve such kind of issues (cc @U04V15CAJ)

borkdude15:05:55

> Let me ask more on this. What if I had a 3rd-party Java library which spawns an instance of Random in a class? Obviously I cannot fix their code. The solution is to initialize this class at runtime and never use it as a top level expression in Clojure

igrishaev15:05:21

ah, maybe that time I had it on the top level, thank you.