# Calling a function breaks REPL in Juno -- ERROR: unlock from wrong thread

**URL:** <https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165>\
**Category:** General Usage\
**Tags:** question, juno, bug\
**Created:** [March 18, 2020, 11:09pm UTC](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165 "2020-03-18T23:09:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)\
**Post date:** [March 18, 2020, 11:09pm UTC](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165/1 "2020-03-18T23:09:26Z")

</div>

Running the code below in Juno renders the REPL broken, and by that I mean I can no longer run anything from the REPL. I’m trying to do more than just a simple wrapper function, but the code below was the minimum needed to reproduce the error.

```julia
using GeoArrays

function read_raster(path)
    a = GeoArrays.read(path)
    a
end

read_raster("test/input/some_raster.asc")

```

where `"test/input/some_raster.asc"` is a file on my local system. Once I run the above, running `2+2` from the REPL does not produce any output (it just hangs) and pressing ctrl-c to interrupt it results in the following:

```julia
julia> 2+2
^CERROR: InterruptException:
Stacktrace:
 [1] poptaskref(::Base.InvasiveLinkedListSynchronized{Task}) at ./task.jl:702
 [2] wait() at ./task.jl:709
 [3] wait(::Base.GenericCondition{Base.Threads.SpinLock}) at ./condition.jl:106
 [4] lock(::ReentrantLock) at ./lock.jl:80
 [5] evalrepl(::Module, ::String) at /root/.julia/packages/Atom/cYxbS/src/repl.jl:221
 [6] top-level scope at /root/.julia/packages/Atom/cYxbS/src/repl.jl:272
 [7] eval(::Module, ::Any) at ./boot.jl:331
 [8] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [9] macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
 [10] (::REPL.var"#26#27"{REPL.REPLBackend})() at ./task.jl:358
ERROR: unlock from wrong thread
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] unlock(::ReentrantLock) at ./lock.jl:101
 [3] evalrepl(::Module, ::String) at /root/.julia/packages/Atom/cYxbS/src/repl.jl:251
 [4] top-level scope at /root/.julia/packages/Atom/cYxbS/src/repl.jl:272

```

Also of note – neither this:

```julia
using GeoArrays

function read_raster(path)
    a = GeoArrays.read(path)
    a.A
end

read_raster("test/input/temperature.asc")

```

nor this

```julia
using GeoArrays
a = GeoArrays.read(path)

```

cause the same error.

I tried removing then installing uber-juno and julia-client in atom but that didn’t help.

I wasn’t sure if this should be posted as an issue in the either the Juno or Julia repo – I thought the discourse might be a good place to start.

Here’s my version info:

```julia
julia> versioninfo()
Julia Version 1.4.0-rc2.0
Commit b99ed72c95 (2020-02-24 16:51 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) E-2176M CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 11
  JULIA_EDITOR = atom -a

```

P.S. I’m working in a Docker image, so it should be possible to replicate this issue on any system.

---

<div class="post-metadata">

**Author:** ![logankilpatrick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/logankilpatrick/32/38123_2.png) [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)\
**Post date:** [March 19, 2020, 11:40am UTC](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165/2 "2020-03-19T11:40:45Z")

</div>

Can you upload that file here for testing purposes?

---

<div class="post-metadata">

**Author:** ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)\
**Post date:** [March 19, 2020, 3:37pm UTC](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165/3 "2020-03-19T15:37:49Z")

</div>

Here’s [a link to the file on github](https://github.com/Circuitscape/Omniscape.jl/blob/master/test/input/temperature.asc).

And FWIW, here’s the Dockerfile:

```julia
# Dockerfile written by Vincent Landau
# Built upon jamesnetherton's atom Dockerfile (here: 
# https://hub.docker.com/r/jamesnetherton/docker-atom-editor/dockerfile) 

FROM ubuntu:18.04

ENV ATOM_VERSION v1.41.0

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      ca-certificates \
      curl \
      fakeroot \
      gconf2 \
      gconf-service \
      git \
      policykit-1 \
      gvfs-bin \
      libasound2 \
      libcap2 \
      libgconf-2-4 \
      libgcrypt20 \
      libgtk2.0-0 \
      libgtk-3-0 \
      libnotify4 \
      libnss3 \
      libx11-xcb1 \
      libxkbfile1 \
      libxss1 \
      libxtst6 \
      libgl1-mesa-glx \
      libgl1-mesa-dri \
      python \
      xdg-utils --no-install-recommends && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    curl -L https://github.com/atom/atom/releases/download/${ATOM_VERSION}/atom-amd64.deb > /tmp/atom.deb && \
    dpkg -i /tmp/atom.deb && \
    rm -f /tmp/atom.deb

# Install julia
RUN curl -L https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.0-rc2-linux-x86_64.tar.gz > /tmp/julia.tar.gz
RUN tar -zxvf /tmp/julia.tar.gz
RUN ln -s /julia-1.4.0-rc2/bin/julia /usr/bin/julia

RUN apm install uber-juno

# Install julia packages so they don't need to be 
# install from stratch when Julia is started in Atom
RUN julia -e 'using Pkg; Pkg.add("GeoArrays")'

RUN julia -e 'using Pkg; Pkg.add(["Juno","Atom"])'

# Install Circuitscape and dependencies

RUN apt-get update && apt-get install -y zlib1g-dev
RUN julia -e 'using Pkg; Pkg.add(["Circuitscape", "BenchmarkTools"])'

CMD ["/usr/bin/atom","-f"]

```

I share my display on Linux with Docker so Atom can be launched on my desktop:

```julia
xhost local:root
docker run -i -d --rm --ipc "host" -v /tmp/.X11-unix/:/tmp/.X11-unix/ \
              	   -v $HOME/.atom:/root/.atom \
              	   -v "$(pwd)":/home/omniscape \
              	   -e DISPLAY \
              	   -e JULIA_NUM_THREADS=4 \
              	   vlandau/juno:1.4.0-rc2

```

---

<div class="post-metadata">

**Author:** ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)\
**Post date:** [March 20, 2020, 6:57pm UTC](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165/4 "2020-03-20T18:57:16Z")

</div>

May be related to [JunoLab/Juno.jl/issues/501](https://github.com/JunoLab/Juno.jl/issues/501). I posted a comment there.

---

<div class="post-metadata">

**Author:** ![vlandau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vlandau/32/8986_2.png) [@vlandau](https://discourse.julialang.org/u/vlandau)\
**Post date:** [March 25, 2020, 5:29pm UTC](https://discourse.julialang.org/t/calling-a-function-breaks-repl-in-juno-error-unlock-from-wrong-thread/36165/5 "2020-03-25T17:29:53Z")

</div>

This was fixed with [JunoLab/Atom.jl/pull/300](https://github.com/JunoLab/Atom.jl/pull/300) and the patch was released in Atom.jl v0.12.10
