Julia Crashes withTerminal Process Error when excuting plotting functions from Agents.jl pkg

Hi,

Julia crashes with the following error when I execute abm_plot() or abm_play() functions from agents.jl package.

The terminal process "julia '-i', '--banner=no', '--project=/Users/imantha/.julia/environments/v1.7', '/Users/imantha/.vscode/extensions/julialang.language-julia-1.5.6/scripts/terminalserver/terminalserver.jl', '/var/folders/_1/j0f_5zq95qd_2dpzlmfh8njm0000gn/T/vsc-jl-repl-953781b4-ea37-4157-b1d8-3f66b4098fa6', '/var/folders/_1/j0f_5zq95qd_2dpzlmfh8njm0000gn/T/vsc-jl-cr-cbe88cd0-df11-4fb8-b504-978d30ec9150', 'USE_REVISE=true', 'USE_PLOTPANE=true', 'USE_PROGRESS=true', 'DEBUG_MODE=false'" terminated with exit code: 139.

Any Ideas perhaps why?
Details

  • Julia 1.7
  • vscode
  • macbook pro (m1 chip)

Environment Details

  • Agents 4.5.7
  • GLMakie 0.4.7
  • InteractiveDynamics 0.18.1

Code

using Pkg
Pkg.activate("envs/abmEnv")
using Agents
using InteractiveDynamics, GLMakie
using Random

# Define Space and Agent type
# --------------------------------------------------------------------------------
space = GridSpace((10,10))
mutable struct Schelling <: AbstractAgent
    id::Int
    pos::Tuple{Int,Int}
    group::Int
    happy::Bool
end

# Initialize Agent Based model
# --------------------------------------------------------------------------------
function initialize(; N = 320, M = 20, min_to_be_happy = 3)
    space = GridSpace((M,M))
    model = AgentBasedModel(
        Schelling,
        space;
        properties = Dict(:min_to_be_happy => min_to_be_happy),
        scheduler = Schedulers.randomly
    )

    for n = 1:N
        agent = Schelling(n, (1,1), (n < N/2) ? 1 : 2, false)
        add_agent_single!(agent, model)
    end

    return model
end

# Agent stepping function
# --------------------------------------------------------------------------------
function agent_step!(agent, model)
    agent.happy && return
    nearby_same = 0
    for neighbor in nearby_agents(agent, model)
        if agent.group == neighbor.group
            nearby_same += 1
        end
    end

    if nearby_same >= model.min_to_be_happy
        agent.happy = true
    else
        move_agent_single!(agent, model)
    end
    return
end

model = initialize()

fig, _ = abm_plot(model, ac = groupcolor, am = groupmarker)
display(fig)

When I type the same code in the Julia REPL I get the following error.

signal (11): Segmentation fault: 11
in expression starting at REPL[18]:1
_buffer_color_type at /Users/imantha/.julia/packages/PNGFiles/TGHP2/src/io.jl:0
#_load#6 at /Users/imantha/.julia/packages/PNGFiles/TGHP2/src/io.jl:149
_load##kw at /Users/imantha/.julia/packages/PNGFiles/TGHP2/src/io.jl:82 [inlined]
#load#2 at /Users/imantha/.julia/packages/PNGFiles/TGHP2/src/io.jl:29
load at /Users/imantha/.julia/packages/PNGFiles/TGHP2/src/io.jl:23
jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_f__call_latest at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:716 [inlined]
invokelatest at ./essentials.jl:714 [inlined]
#load#3 at /Users/imantha/.julia/packages/ImageIO/vgskl/src/ImageIO.jl:53
load at /Users/imantha/.julia/packages/ImageIO/vgskl/src/ImageIO.jl:53
unknown function (ip: 0x13fe7e78b)
jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_f__call_latest at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:716 [inlined]
invokelatest at ./essentials.jl:714 [inlined]
#action#33 at /Users/imantha/.julia/packages/FileIO/FUXWu/src/loadsave.jl:219
action at /Users/imantha/.julia/packages/FileIO/FUXWu/src/loadsave.jl:197 [inlined]
#action#32 at /Users/imantha/.julia/packages/FileIO/FUXWu/src/loadsave.jl:185
action at /Users/imantha/.julia/packages/FileIO/FUXWu/src/loadsave.jl:185 [inlined]
#load#14 at /Users/imantha/.julia/packages/FileIO/FUXWu/src/loadsave.jl:113
load at /Users/imantha/.julia/packages/FileIO/FUXWu/src/loadsave.jl:110 [inlined]
_broadcast_getindex_evalf at ./broadcast.jl:670 [inlined]
_broadcast_getindex at ./broadcast.jl:643 [inlined]
getindex at ./broadcast.jl:597 [inlined]
copy at ./broadcast.jl:899 [inlined]
materialize at ./broadcast.jl:860 [inlined]
icon at /Users/imantha/.julia/packages/Makie/gQOQF/src/Makie.jl:254
unknown function (ip: 0x13fe7b2b3)
#Screen#48 at /Users/imantha/.julia/packages/GLMakie/pFGSp/src/screen.jl:346
Screen at /Users/imantha/.julia/packages/GLMakie/pFGSp/src/screen.jl:301 [inlined]
global_gl_screen at /Users/imantha/.julia/packages/GLMakie/pFGSp/src/screen.jl:247 [inlined]
global_gl_screen at /Users/imantha/.julia/packages/GLMakie/pFGSp/src/screen.jl:394
global_gl_screen at /Users/imantha/.julia/packages/GLMakie/pFGSp/src/screen.jl:393 [inlined]
backend_display at /Users/imantha/.julia/packages/GLMakie/pFGSp/src/display.jl:2 [inlined]
#display#907 at /Users/imantha/.julia/packages/Makie/gQOQF/src/display.jl:60
display at /Users/imantha/.julia/packages/Makie/gQOQF/src/display.jl:56 [inlined]
#display#906 at /Users/imantha/.julia/packages/Makie/gQOQF/src/display.jl:52 [inlined]
display at /Users/imantha/.julia/packages/Makie/gQOQF/src/display.jl:52
jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
do_call at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
eval_body at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_interpret_toplevel_thunk at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_toplevel_eval_in at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
eval at ./boot.jl:373 [inlined]
eval_user_input at /Users/administrator/src/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:150
repl_backend_loop at /Users/administrator/src/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:244
start_repl_backend at /Users/administrator/src/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:229
#run_repl#47 at /Users/administrator/src/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:362
run_repl at /Users/administrator/src/julia/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:349
jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
#930 at ./client.jl:394
jfptr_YY.930_43775 at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_f__call_latest at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:716 [inlined]
invokelatest at ./essentials.jl:714 [inlined]
run_main_repl at ./client.jl:379
exec_options at ./client.jl:309
_start at ./client.jl:495
jl_sysimg_fvars_base at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
true_main at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_repl_entrypoint at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)
Allocations: 179925494 (Pool: 179887488; Big: 38006); GC: 98
1 Like

Try giving this a go to get more info as to what’s crashing your REPL.

It’s hard for me to say anything about this since I neither use an M1 chip nor Julia 1.7. However, you could probably eliminate one of the possible causes by trying to run the same code with the same package versions in a Julia 1.6.4 session.

@imantha Did you ever figure out what to do about this?
I have just recently gotten a new M1 Macbook and I run into the same problem.

1 Like

Did you try it out with a Julia LTS version?

Originally I got the following error:

The terminal process "julia '-i', '--banner=no', '--project=/Users/michelsen/work/diffusion/julia', '/Users/michelsen/.vscode/extensions/julialang.language-julia-1.5.10/scripts/terminalserver/terminalserver.jl', '/var/folders/rt/v4y9l7f92pg7y0jqv03pfn0h0000gn/T/vsc-jl-repl-a8fd5130-7897-45c6-8861-a102f3505ddf', '/var/folders/rt/v4y9l7f92pg7y0jqv03pfn0h0000gn/T/vsc-jl-cr-856fc3db-f484-49ae-8b69-30256cd03ad3', 'USE_REVISE=true', 'USE_PLOTPANE=true', 'USE_PROGRESS=true', 'DEBUG_MODE=false'" terminated with exit code: 139.

I then tried v1.6.5 and it worked. Following that, I tried the v1.7.2 x86-version, also without any issues. So now I am using the v1.7.2 x86-version with Rosetta, however, it would be nice to be able to use the native version.

This was happening in VS Code and macOS Montery (12.2) and an M1 Pro.

Let me know if I can be of any help during the debugging!

+1
I am in the same boat.
Everything works well in the real REPL.
But jupyter lab/notebook kernels break as well.

EDIT:
Of course it is more tricky.
Some plots seam to work and some do not.
Functions from Plots and StatsPlots work, some of my own do not.

+1 same issue.
I just followed along Makie tutorial
https://makie.juliaplots.org/stable/tutorials/basic-tutorial/
instead of CairoMakie, I used GLMakie. terminal crashes with the same error
My system: M1 mac mini
I switched to Julia 1.7 x86 (Rosetta) following @wc4wc4wc4 advice. Now it works!
as he said, it would be nice if julia M-Series versions move from experimental to stable.

Me 3. I think that Julia for M1 is a bit experimental and few if any of the maintainers have an M1 Mac so that it is hard to do much testing.

Sorry for the extremely late reply. Similar to you I got it working on julia 1.7 after installing another version of julia (1.6.5) in my mac. But after some time the same error started repeating itself. So no clue whats going on …

I’m using Fedora 36 and get the same error using Julia 1.7.2.
I have old HP Z1 2012.

Can you guys please first clarify if this is an Agents.jl issue, or a Makie.jl issue? I.e., plotting with Makie works fine by itself?

I’m getting it with GameZero.jl, but others as far as I udnerstand are getting it on Makie.jl and Agents.jl. Which I think means that it’s a Makie issue, since Agents package is using Makie as far as I know.

I am running into the same issue with CairoMakie.jl – Julia keep crashing in vscode every time I try to plot

Julia Version 1.7.2
OS: macOS (arm64-apple-darwin21.2.0)
CPU: Apple M1 Pro

I am resisting switching to the rosetta version hoping this would get resolved in an update, but might have to make the switch now.

I get the same error when just trying to run plot() with the plots package on VS code. I tried first with v.1.7.3 and then the LTS version 1.6.6 but still the same error. I’m using straight up windows (x86_64-w64-mingw32).

Anyone know what might be the cause for this?

Start a new terminal (integrated or external) and manually start Julia within that terminal. Then use the Julia: Connect external REPL command and follow the instructions. After the Julia session is connected to VS Code, run your code as before; the terminal will stay open after Julia closes.