A weird issue with Julia-1.7.1. on Ubuntu (GibbsSeaWater.jl package)

The bleow script runs perfectly fine on my Macbook Pro with Julia-1.7.1, but the same program does not run at all on Ubuntu (20.04) (Julia-1.7.1) and gives me the below error message. Not sure if it is due to Julia itself or the package GibbsSeaWater.jl.

Here is a MAT file with some sample data: test.mat - Google Drive

Here is my code:

using MAT, GibbsSeaWater;

F1 = matopen("test.mat");
SP  = read(F1, "SP");
P   = read(F1, "P");
Lon = read(F1, "Lon");
Lat = read(F1, "Lat");
close(F1);

SA = gsw_sa_from_sp.(SP, P, Lon, Lat); # calculate the Absolute salinity

Here is the error message.

signal (11): Segmentation fault
in expression starting at /home/leon/Desktop/LQ/Julia_models/ESM4/A06_unit_conv_historical.jl:38
gsw_saar at /home/leon/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/leon/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/leon/.julia/packages/GibbsSeaWater/vq3GE/src/gen_gswteos10.jl:534 [inlined]
_broadcast_getindex_evalf at ./broadcast.jl:670 [inlined]
_broadcast_getindex at ./broadcast.jl:643 [inlined]
getindex at ./broadcast.jl:597 [inlined]
macro expansion at ./broadcast.jl:961 [inlined]
macro expansion at ./simdloop.jl:77 [inlined]
copyto! at ./broadcast.jl:960 [inlined]
copyto! at ./broadcast.jl:913 [inlined]
copy at ./broadcast.jl:885 [inlined]
materialize at ./broadcast.jl:860
unknown function (ip: 0x7fcb1f0a4a5d)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
top-level scope at /home/leon/Desktop/LQ/Julia_models/ESM4/A06_unit_conv_historical.jl:41
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:876
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:830
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:944
eval at ./boot.jl:373 [inlined]
include_string at ./loading.jl:1196
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
_include at ./loading.jl:1253
include at ./Base.jl:418
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
exec_options at ./client.jl:292
_start at ./client.jl:495
jfptr__start_40531.clone_1 at /opt/julia-1.7.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:559
jl_repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:701
main at julia (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x400808)
Allocations: 8021244 (Pool: 8018757; Big: 2487); GC: 7
Segmentation fault (core dumped)

This does not seem to be a performance related issue. It ran on my Mac super fast. On Ubuntu, however, it reported the error message without even trying.

you can test the package with test GibbsSeaWater

my test ( Ubuntu 20.04.3 LTS + Julia 1.7.1 - Linux (x86_64-pc-linux-gnu)

  • new julia install
  • old ( julia 1.6) ~/.julia directory has been removed.
test GibbsSeaWater ( GibbsSeaWater v0.1.1 )
(@v1.7) pkg> st
      Status `~/.julia/environments/v1.7/Project.toml`
  [9a22fb26] GibbsSeaWater v0.1.1

(@v1.7) pkg> test GibbsSeaWater
     Testing GibbsSeaWater
      Status `/tmp/jl_Ow8oLP/Project.toml`
  [b99e7846] BinaryProvider v0.5.10
  [34da2185] Compat v3.41.0
  [9a22fb26] GibbsSeaWater v0.1.1
  [8f399da3] Libdl `@stdlib/Libdl`
  [8dfed614] Test `@stdlib/Test`
      Status `/tmp/jl_Ow8oLP/Manifest.toml`
  [b99e7846] BinaryProvider v0.5.10
  [34da2185] Compat v3.41.0
  [9a22fb26] GibbsSeaWater v0.1.1
  [0dad84c5] ArgTools `@stdlib/ArgTools`
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [8bb1440f] DelimitedFiles `@stdlib/DelimitedFiles`
  [8ba89e20] Distributed `@stdlib/Distributed`
  [f43a241f] Downloads `@stdlib/Downloads`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [b27032c2] LibCURL `@stdlib/LibCURL`
  [76f85450] LibGit2 `@stdlib/LibGit2`
  [8f399da3] Libdl `@stdlib/Libdl`
  [37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [a63ad114] Mmap `@stdlib/Mmap`
  [ca575930] NetworkOptions `@stdlib/NetworkOptions`
  [44cfe95a] Pkg `@stdlib/Pkg`
  [de0858da] Printf `@stdlib/Printf`
  [3fa0cd96] REPL `@stdlib/REPL`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [1a1011a3] SharedArrays `@stdlib/SharedArrays`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [2f01184e] SparseArrays `@stdlib/SparseArrays`
  [10745b16] Statistics `@stdlib/Statistics`
  [fa267f1f] TOML `@stdlib/TOML`
  [a4e569a6] Tar `@stdlib/Tar`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [e66e0078] CompilerSupportLibraries_jll `@stdlib/CompilerSupportLibraries_jll`
  [deac9b47] LibCURL_jll `@stdlib/LibCURL_jll`
  [29816b5a] LibSSH2_jll `@stdlib/LibSSH2_jll`
  [c8ffd9c3] MbedTLS_jll `@stdlib/MbedTLS_jll`
  [14a3606d] MozillaCACerts_jll `@stdlib/MozillaCACerts_jll`
  [4536629a] OpenBLAS_jll `@stdlib/OpenBLAS_jll`
  [83775a58] Zlib_jll `@stdlib/Zlib_jll`
  [8e850b90] libblastrampoline_jll `@stdlib/libblastrampoline_jll`
  [8e850ede] nghttp2_jll `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll `@stdlib/p7zip_jll`
     Testing Running tests...
Test Summary:              | Pass  Total
Practical Salinity, PSS-78 |    3      3
Test Summary:                                                      | Pass  Total
Absolute Salinity, Preformed Salinity and Conservative Temperature |    3      3
Test Summary:                                                                    | Pass  Total
Other conversions between Temperatures, Salinities, Entropy, Pressure and Height |   18     18
Test Summary:                         | Pass  Total
Specific Volume, Density and Enthalpy |   38     38
     Testing GibbsSeaWater tests passed 
1 Like

Thanks! I got a “pass” for my test. Unfortunately, the error persists.

Here is a MAT file with some sample data: test.mat - Google Drive

Here is my code:

using MAT, GibbsSeaWater;

F1 = matopen("test.mat");
SP  = read(F1, "SP");
P   = read(F1, "P");
Lon = read(F1, "Lon");
Lat = read(F1, "Lat");
close(F1);

SA = gsw_sa_from_sp.(SP, P, Lon, Lat); # calculate the Absolute salinity
1 Like

Simplified test code:

using GibbsSeaWater

# julia> i=79; (SP[i], P[i], Lon[i], Lat[i])
# (34.05199699401855, 10.0, 377.5, -62.5)

# gsw_sa_from_sp(34.0, 10.0, 377.5, -62.5)
gsw_saar(10.0, 377.5, -62.5)

Is 377.5 a legal longitude?

julia> Lon[61:82]
22-element Vector{Float64}:
 359.5
 360.5
 361.5
 362.5
 363.5
 364.5
 365.5
 366.5
 367.5
 368.5
 369.5
 370.5
 371.5
 372.5
 373.5
 374.5
 375.5
 376.5
 377.5
 378.5
 379.5
  20.5

Next you can compile GSW-C in debug mode, then call gsw_saar with the same arguments and debug with gdb to find out which line is wrong.

Breakpoint 6, gsw_saar (p=10, lon=377.5, lat=-62.5) at gsw_saar.c:69
69              indx0   = floor(0 + (nx-1)*(lon-longs_ref[0])/(longs_ref[nx-1]-
70                          longs_ref[0]));
(gdb) p nx
$13 = 91
(gdb) p lon
$14 = 377.5
(gdb) p longs_ref[0]
$15 = 0
(gdb) p longs_ref[nx - 1]
$16 = 360

When lon > 360, indx0 > (nx-1), which then causes the array (longs_ref[indx0]) to go out of bounds.


I can reproduce the error in WSL (Ubuntu 20.04.3 LTS).

julia> SA = gsw_sa_from_sp.(SP, P, Lon, Lat);

signal (11): Segmentation fault
in expression starting at REPL[10]:1
gsw_saar at /home/woclass/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/woclass/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/woclass/.julia/packages/GibbsSeaWater/vq3GE/src/gen_gswteos10.jl:534 [inlined]

On Windows, everything works fine.

win REPL
julia> SA
201-element Vector{Float64}:
 33.978850980733235
 34.112732625974715
 34.20779818246909
 34.26127607610699
 34.29615007324156
 34.29711167161423
 34.28884564139484
 34.318206662266995
 34.32395340273992
 34.33207869075504
 34.345693213139945
 34.36708801832739
 34.374648814324125
  ⋮
 33.96205590976534
 33.957670222578585
 33.948449301367084
 33.937740328020595
 33.93005643268858
 33.92895873943964
 33.93384238282935
 33.93726330942629
 33.93330105293442
 33.92392157797163
 33.91456389969976
 33.908278813955846

(@v1.7) pkg> st
      Status `C:\Users\woclass\.julia\environments\v1.7\Project.toml`
  [6e4b80f9] BenchmarkTools v1.2.2
  [31a5f54b] Debugger v0.6.8
  [9a22fb26] GibbsSeaWater v0.1.1
  [23992714] MAT v0.10.2

julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
2 Likes

Ouch …
I can replicate the error - with your code … ( Ubuntu20.04 X86-64 + Julia 1.7.1 )

IMHO: You have to create an issue in the project repo:

Crash log - Segmentation fault (core dumped)
(@v1.7) pkg> ^C

julia> using MAT, GibbsSeaWater;

julia> F1 = matopen("test.mat");

julia> SP  = read(F1, "SP");

julia> P   = read(F1, "P");

julia> Lon = read(F1, "Lon");

julia> Lat = read(F1, "Lat");

julia> close(F1);

julia> SA = gsw_sa_from_sp.(SP, P, Lon, Lat); # calculate the Absolute salinity

signal (11): Segmentation fault
in expression starting at REPL[11]:1
gsw_saar at /home/pella/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/pella/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/pella/.julia/packages/GibbsSeaWater/vq3GE/src/gen_gswteos10.jl:534 [inlined]
_broadcast_getindex_evalf at ./broadcast.jl:670 [inlined]
_broadcast_getindex at ./broadcast.jl:643 [inlined]
getindex at ./broadcast.jl:597 [inlined]
macro expansion at ./broadcast.jl:961 [inlined]
macro expansion at ./simdloop.jl:77 [inlined]
copyto! at ./broadcast.jl:960 [inlined]
copyto! at ./broadcast.jl:913 [inlined]
copy at ./broadcast.jl:885 [inlined]
materialize at ./broadcast.jl:860
unknown function (ip: 0x7f00ff86444d)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:126
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:215
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:166 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:587
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:731
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:885
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:830
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:830
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:944
eval at ./boot.jl:373 [inlined]
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:150
repl_backend_loop at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:244
start_repl_backend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:229
#run_repl#47 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:362
run_repl at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:349
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
#930 at ./client.jl:394
jfptr_YY.930_40362.clone_1 at /usr/local/julia/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
#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_40531.clone_1 at /usr/local/julia/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:559
jl_repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:701
main at julia (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x400808)
Allocations: 19134489 (Pool: 19123101; Big: 11388); GC: 25
Segmentation fault (core dumped)

I have tested the master version - same result :cry:
(@v1.7) pkg> add https://github.com/TEOS-10/GibbsSeaWater.jl#master

  • → Segmentation fault (core dumped)
1 Like

@woclass – Thank you so much. This indeed fixes the issue! :+1:

@ImreSamu – Yes, I’ll open up an issue there. It is common for my community to use a 20-380 degree system. That way, all the major oceans are in one piece.