In VSCode, "terminated with exit code: 139"

Hello! I am trying out a function I have written to implement the power method. I am filling a CSRMatrix (a type created in the project I am working on) and then running my function with that matrix. I have no problems when I just fill the matrix OR when I just run the function on an unfilled matrix. However, if I try to fill the matrix and use my function, the Julia REPL crashes and the error in the attached screenshot appears.

From some googling, it seems like the issue has to do with a file being read/written to, but I do not know how to start with fixing it. Does anyone have any ideas?

I appreciate any help, thanks!

139 usually indicates a segfault. Try the instructions here to hopefully get a stacktrace.

Thank you for the response. I tried the tmux approach, but the Julia REPL still crashed (the bash terminal stayed open, but no error messages appeared there) so I could not see the error message. Does that mean I didn’t use tmux properly?

Try the second approach and post the output here. It’s definitely possible, but rare, for Julia to die without any output. In that case, I’d recommend trying to repro the issue in a normal REPL (without the VS Code integration loaded) and run Julia through gdb or RR.

Could you also run versioninfo()and post the results?

Here’s my version info:

Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin21.4.0)
  CPU: Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
 Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 

I’m having trouble figuring out how to run my code with the External REPL command.

Does it only happen in VSCode and not when you run the same code in an (external) REPL? You could try running julia with --check-bounds=yes to check for out of bounds indexing.

When I run it in an external REPL, the seg fault still happens, but this time I can see the error message:

signal (11): Segmentation fault: 11

in expression starting at /Users/fionasmith/SandiaJuliaWork/tryPower.jl:104

* at ./float.jl:404 [inlined]

localApply at /Users/fionasmith/.julia/packages/JuliaPetra/JBvpV/src/CSRMatrix.jl:1039

power1 at /Users/fionasmith/SandiaJuliaWork/tryPower.jl:69

unknown function (ip: 0x102379094)

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]

include_string at ./loading.jl:1196

jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)

_include at ./loading.jl:1253

include at ./client.jl:451

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/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:150

repl_backend_loop at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:246

start_repl_backend at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:231

#run_repl#47 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:364

run_repl at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:351

jl_apply_generic at /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib (unknown line)

#936 at ./client.jl:394

jfptr_YY.936_47061.clone_1 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

jfptr__start_33485.clone_1 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: 10776274 (Pool: 10771648; Big: 4626); GC: 13

[Process completed]

So is the error originating with the localApply function that I am using in tryPower.jl?

The @inbounds here may be the culprit

Do give Fredrik’s suggestion of running Julia with --check-inbounds=yes a go.

When I run:

./tryPower.jl --check-inbounds=yes

I get errors that have not come up before (

./tryPower.jl: line 1: using: command not found

./tryPower.jl: line 5: syntax error near unexpected token `A::Matrix{},'

./tryPower.jl: line 5: `function power(A::Matrix{}, niter::Integer, tol::Float64)'

). Perhaps I am not running this correctly?

Ah, my bad, that’s a typo. It should be something like julia --check-bounds=yes ./tryPower.jl.

It says

bash: julia: command not found.

Ok, you don’t have julia on your path. Use the full path from that error message in your screenshot (/Applications/...) instead of julia in that code snippet.

I apologize for all of these errors, but now this comes up.

bash: /Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.7.dylib: cannot execute binary file
/Applications/Julia-1.7.app/Contents/Resources/julia/bin/julia --check-bounds=yes ./tryPower.jl

should be the right one.

**ERROR:** LoadError: MPI not properly installed. Please run Pkg.build("MPI")

Stacktrace:

[1] **error(**s::String**)**

@ Base ./error.jl:33

[2] top-level scope

@ ~/.julia/packages/MPI/U5ujD/src/MPI.jl:15

[3] **include**

@ ./Base.jl:418 [inlined]

[4] **include_package_for_output(**pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String**)**

@ Base ./loading.jl:1318

[5] top-level scope

@ none:1

[6] **eval**

@ ./boot.jl:373 [inlined]

[7] **eval(**x::Expr**)**

@ Base.MainInclude ./client.jl:453

[8] top-level scope

@ none:1

in expression starting at /Users/fionasmith/.julia/packages/MPI/U5ujD/src/MPI.jl:3

**ERROR:** LoadError: InitError: LoadError: Failed to precompile MPI [da04e1cc-30fd-572f-bb4f-1f8673147195] to /Users/fionasmith/.julia/compiled/v1.7/MPI/jl_FjyIJO.

Stacktrace:

[1] **error(**s::String**)**

@ Base ./error.jl:33

[2] **compilecache(**pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool**)**

@ Base ./loading.jl:1466

[3] **compilecache(**pkg::Base.PkgId, path::String**)**

@ Base ./loading.jl:1410

[4] **_require(**pkg::Base.PkgId**)**

@ Base ./loading.jl:1120

[5] **require(**uuidkey::Base.PkgId**)**

@ Base ./loading.jl:1013

[6] **require(**into::Module, mod::Symbol**)**

@ Base ./loading.jl:997

[7] **include(**mod::Module, _path::String**)**

@ Base ./Base.jl:418

[8] **include**

@ ~/.julia/packages/JuliaPetra/JBvpV/src/JuliaPetra.jl:3 [inlined]

[9] **__init__()**

@ JuliaPetra ~/.julia/packages/JuliaPetra/JBvpV/src/JuliaPetra.jl:60

[10] **_include_from_serialized(**path::String, depmods::Vector{Any}**)**

@ Base ./loading.jl:768

[11] **_require_search_from_serialized(**pkg::Base.PkgId, sourcepath::String**)**

@ Base ./loading.jl:854

[12] **_require(**pkg::Base.PkgId**)**

@ Base ./loading.jl:1097

[13] **require(**uuidkey::Base.PkgId**)**

@ Base ./loading.jl:1013

[14] **require(**into::Module, mod::Symbol**)**

@ Base ./loading.jl:997

in expression starting at /Users/fionasmith/.julia/packages/JuliaPetra/JBvpV/src/MPIUtil.jl:2

during initialization of module JuliaPetra

in expression starting at /Users/fionasmith/SandiaJuliaWork/tryPower.jl:1

But when I run Pkg.build(“MPI”) it returns

-bash: syntax error near unexpected token `"MPI"'

Probably best if you start a REPL session with

/Applications/Julia-1.7.app/Contents/Resources/julia/bin/julia --check-bounds=yes

and then activate the right project manually, after which include("tryPower.jl") should do the right thing.

The line you mentioned above is in fact where the error is originating.

@inbounds sum += val*rawX[ind, vect]

LoadError: BoundsError: attempt to access 2×1 Matrix{Float32} at index [0, 1]

Thank you for your help! I will see what I can do to fix this invalid indexing.