Fork me on GitHub
#graalvm
<
2020-12-31
>
borkdude19:12:02

Hmm, I'm running into a locking issue with clojure 1.10-rc2 and GraalVM 20.3.0. Repro code:

(ns pod.babashka.lock
  (:gen-class))

(def ^:private hosts-file
  "Something to lock to tray and prevent concurrent updates/reads to
  hosts file."
  (Object.))

(defn -main [& _args]
  (locking hosts-file
    (prn (+ 1 2 3))))
GraalVM native-image output:
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
 This frame state: [locals: [1,5,_,_] stack: [9] locks: [] rethrowException]
Other frame state: [locals: [1,5,_,_] stack: [23] locks: [16 / 7] rethrowException]
Parser context: pod.babashka.lock$_main.invokeStatic(lock.clj:11) [bci: 17, intrinsic: false]
  17: checkcast     #26         // clojure.lang.IFn
  20: lconst_1
  21: ldc2_w        #27         // 2
  24: invokestatic  #4          // clojure.lang.Numbers.add:(long, long)long
  27: ldc2_w        #35         // 3

borkdude19:12:11

This does seem to work:

(defn -main [& _args]
  (let [x (Object.)]
    (locking x
      (prn (+ 1 2 3)))))

borkdude19:12:16

This may be false alarm because when I macroexpand I think I'm seeing the old locking macro code.

borkdude19:12:54

although 1.10.2-rc2 should be used according to -Stree and such

ghadi19:12:40

1.10.2-rc2 doesn't exist, only 1.10.2-rc1

borkdude19:12:07

yeah sorry, typo. Gosh, it seems depstar isn't picking up rc1 even when I include that in my aliases

borkdude19:12:24

when I print the clojure version at compile time I get 1.10.1

ghadi19:12:40

perhaps depstar is confused?

borkdude19:12:09

I think depstar now has a new :aliases arg

borkdude19:12:36

so probably I was confused

borkdude19:12:17

all good now, sorry for the noise and happy new year!