Fork me on GitHub
#clojure-dev
<
2021-02-17
>
ghadi02:02:11

@hiredman in the clojure.main repl you can override eval to e.g. add a wrapper that submitted code somewhere central for tooling, but that doesn't seem possible with prepl - eval is hardcoded so any envelope would have to be added by the submitter, not the REPL receiver

borkdude07:02:51

@seancorfield note that interrupted eval in nREPL relies on Thread#stop which is deprecated and not even available anymore in newer VMs like GraalVM (this is why bb doesn’t support this in its REPLs)

andy.fingerhut09:02:48

As far as I have seen, every REPL that supports interruptable eval uses Thread#stop today. I have only confirmed with nREPL 0.6.0 with Lein 2.9.3 and unrepl / unravel, but there really is no other mechanism that can be used to stop a thread that is in a "ignore the world" infinite loop, i.e. that doesn't use the recommended method of avoiding Thread#stop because it checks for some global variable change or similar thing in its inner loops.

andy.fingerhut09:02:01

It makes perfect sense to me that Thread#stop is deprecated -- not trying to argue against deprecating it. It makes sense why people decide to use it anyway.

andy.fingerhut09:02:27

(well, many of them without knowing they are using it, perhaps)

borkdude09:02:28

Yes, I wish it was just available in GraalVM

andy.fingerhut09:02:36

Thread#stop is still available in JDK 15, FYI -- I haven't checked JDK 16.

seancorfield17:02:06

Yeah, @hiredman pointed that out in a thread to me, and I think he did a quick check and that's how they all work -- because it's all there is on the JVM right now (unless your compiled code includes collaborative checks on a global "abort" flag). He also shared some code with me that made me feel a bit better about building something very simple and prepl-based that might provide the sort of minimal almost-no-code REPL that I'd like to see (but, frankly, at this point I doubt anyone is going to unseat nREPL).

hiredman17:02:42

the jvm tooling interface (I guess what jvm agents use?) has an optional command to kill threads too https://docs.oracle.com/en/java/javase/15/docs/specs/jvmti.html#StopThread which it says is like Thread.stop, but I don't see a bunch of "Keep Out" signs posted all around it

andy.fingerhut17:02:43

Probably they figured that if you read that, you will read the docs for Thread#stop, too. I would guess there are a lot of potential 'here be dragons' methods in tooling interfaces besides that issue.

devn07:02:00

You can’t take my SIGKILL away!