# In VSCode, "terminated with exit code: 139"

**URL:** https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765
**Category:** General Usage
**Created:** [July 25, 2022, 5:00pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765 "2022-07-25T17:00:40Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 25, 2022, 5:00pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/1 "2022-07-25T17:00:40Z")

</div>

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.

 ![Screen Shot 2022-07-25 at 10.55.12 AM](https://global.discourse-cdn.com/julialang/original/3X/2/3/2383407f3d27a4cf74d122d37de5911819ae03c5.png)

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!

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [July 25, 2022, 5:47pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/2 "2022-07-25T17:47:41Z")

</div>

139 usually indicates a segfault. Try the instructions [here](https://www.julia-vscode.org/docs/stable/faq/#The-integrated-REPL-closes-when-the-Julia-process-crashes.-How-do-I-get-more-information-on-what's-going-on?) to hopefully get a stacktrace.

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 25, 2022, 6:27pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/3 "2022-07-25T18:27:32Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [July 25, 2022, 7:14pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/4 "2022-07-25T19:14:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gbaraldi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gbaraldi/32/22101_2.png) [@gbaraldi](https://discourse.julialang.org/u/gbaraldi)
#### Post date: [July 25, 2022, 7:16pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/5 "2022-07-25T19:16:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 25, 2022, 7:32pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/6 "2022-07-25T19:32:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [July 25, 2022, 7:38pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/7 "2022-07-25T19:38:44Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 26, 2022, 7:20pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/8 "2022-07-26T19:20:23Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [July 27, 2022, 11:38am UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/9 "2022-07-27T11:38:30Z")

</div>

The `@inbounds` here may be the culprit

> <https://github.com/Collegeville/JuliaPetra.jl/blob/e37cfe6fcda8e126f64b6452e04156ef980fb356/src/CSRMatrix.jl#L1039>

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

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 27, 2022, 4:14pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/10 "2022-07-27T16:14:31Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [July 27, 2022, 4:15pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/11 "2022-07-27T16:15:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 27, 2022, 4:20pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/12 "2022-07-27T16:20:49Z")

</div>

It says

```
bash: julia: command not found.

```

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [July 27, 2022, 4:26pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/13 "2022-07-27T16:26:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 27, 2022, 4:36pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/14 "2022-07-27T16:36:01Z")

</div>

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

```

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [July 27, 2022, 4:49pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/15 "2022-07-27T16:49:28Z")

</div>

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

```

should be the right one.

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 27, 2022, 4:59pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/16 "2022-07-27T16:59:20Z")

</div>

```
**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"'

```

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [July 27, 2022, 5:01pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/17 "2022-07-27T17:01:24Z")

</div>

Probably best if you start a REPL session with

```julia
/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.

---

<div class="post-metadata">

### Author: ![fsmith001](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fsmith001/32/37173_2.png) [@fsmith001](https://discourse.julialang.org/u/fsmith001)
#### Post date: [July 27, 2022, 5:33pm UTC](https://discourse.julialang.org/t/in-vscode-terminated-with-exit-code-139/84765/18 "2022-07-27T17:33:56Z")

</div>

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.
