Hard to find bug in julia 1.0.0

I ported a rather large module called Tbl from julia 0.6 to 1.0, verifying step by step that everything works, which it does. However, when using Tbl after it has been modified in any way in a new julia session, I get an error at the end (after parsing everything, a message printed at the end of the loaded file appears) and julia exits. The error message is pasted below. What’s funny is if I then restart julia and use again Tbl, everything works! This looks hard to debug. Any suggestions?

 signal (11): Erreur de segmentation
in expression starting at no file:0
jl_gc_pool_alloc at /buildworker/worker/package_linux64/build/src/gc.c:963
jl_gc_alloc_ at /buildworker/worker/package_linux64/build/src/julia_internal.h:274 [inlined]
jl_gc_alloc at /buildworker/worker/package_linux64/build/src/gc.c:2668
_new_array_ at /buildworker/worker/package_linux64/build/src/array.c:99
jl_deserialize_value_array at /buildworker/worker/package_linux64/build/src/dump.c:1518
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:2023
jl_deserialize_value_array at /buildworker/worker/package_linux64/build/src/dump.c:1532
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:2023
jl_deserialize_value_array at /buildworker/worker/package_linux64/build/src/dump.c:1532
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:2023
jl_deserialize_struct at /buildworker/worker/package_linux64/build/src/dump.c:1859
jl_deserialize_value_any at /buildworker/worker/package_linux64/build/src/dump.c:1958 [inlined]
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:2155
jl_deserialize_value_array at /buildworker/worker/package_linux64/build/src/dump.c:1532
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:2023
jl_deserialize_struct at /buildworker/worker/package_linux64/build/src/dump.c:1859
jl_deserialize_value_any at /buildworker/worker/package_linux64/build/src/dump.c:1958 [inlined]
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:2155
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:1773
jl_deserialize_value_array at /buildworker/worker/package_linux64/build/src/dump.c:1532
jl_deserialize_value at /buildworker/worker/package_linux64/build/src/dump.c:2023
_jl_restore_incremental at /buildworker/worker/package_linux64/build/src/dump.c:3084
jl_restore_incremental at /buildworker/worker/package_linux64/build/src/dump.c:3141
_include_from_serialized at ./loading.jl:614
_require_from_serialized at ./loading.jl:678
_require at ./logging.jl:317
require at ./loading.jl:852
macro expansion at ./logging.jl:311 [inlined]
require at ./loading.jl:834
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1536 [inlined]
call_require at /buildworker/worker/package_linux64/build/src/toplevel.c:441 [inlined]
eval_import_path at /buildworker/worker/package_linux64/build/src/toplevel.c:476
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:633
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/builtins.c:622
eval at ./boot.jl:319
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:85
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:259
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1536 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
Allocations: 1087742 (Pool: 1087294; Big: 448); GC: 1
Erreur de segmentation (core dumped)

Check for left over deprecations maybe? You really should be using 0.7 when upgrading code from 0.6.

1 Like

The bug is exactly the same in 0.7 with no deprecation warning. After a lot of dichotomy of files, I managed to reduce the bug to a reproducible in my installation (ubuntu-linux) bug. Create a file Bug.jl with the following contents:

module Bug
using Combinatorics

v=[[], [62], [[60], [51]], [50], [[60], [59]],
[missing, 32], [missing, 42], [missing, 40], [missing, missing, 30], 
[7, missing, 25], [13, missing, 25], [2, missing, 30], [11, missing, 25], 
[missing, missing, missing, 24], [14, missing, missing, missing, 16], 
[12, missing, missing, missing, 16], [missing, 2, missing, missing, 20], 
[14, 8, missing, missing, 12], [2, missing, missing, missing, 20], 
[[3, 2, missing, missing, 19], [missing, 6, missing, missing, 17]],
[[3, 2, missing, missing, 19], [2, 2, missing, missing, 19]],
[missing, missing, missing, missing, missing, 18], 
[3, missing, missing, missing, missing, missing, 15], 
[missing, missing, 1, missing, missing, missing, 15], 
[missing, missing, missing, missing, missing, missing, missing, 14], 
[2, missing, missing, missing, missing, missing, missing, missing, 12], 
[1, 4, 7, missing, 2, missing, missing, missing, missing, missing, 6], 
[1, missing, 7, missing, 4, missing, missing, missing, missing, missing, 6], 
[missing, 2, missing, missing, missing, missing, missing, missing, missing, 
 missing, 10], [missing, 2, missing, 6, missing, missing, missing, missing, 
missing, missing, missing, missing, missing, 6], [63], [33], [51], [61], [59], 
[15, missing, missing, missing, 16], [missing, missing, missing, missing, 21], 
[3, missing, missing, missing, 20], [3, missing, 30], [[12, missing, 25], 
[7, missing, 25]], [6, missing, 25], [1, missing, 30], [[12, missing, 25], 
[11, missing, 25]], [3, missing, missing, missing, missing, missing, missing, 
missing, 12], [9, 16, missing, missing, 8], [15, 8, missing, missing, 12], 
[missing, 8, missing, missing, 17], [13, missing, missing, missing, 16], 
[3, 20, missing, missing, 10], [missing, 6, missing, missing, 17], 
[2, 2, missing, missing, 19], [missing, missing, missing, missing, missing, 
     missing, missing, missing, missing, missing, missing, missing, 9], 
[2, missing, missing, missing, missing, missing, 15], 
[1, missing, 1, missing, missing, missing, 15], 
[missing, missing, missing, missing, missing, missing, missing, missing, 
 missing, missing, missing, missing, missing, missing, missing, missing, 7], 
[3, missing, missing, 12, missing, missing, missing, missing, 6], 
[missing, missing, 7, missing, 4, missing, missing, missing, missing, missing, 
 6], 
[missing, 4, 7, missing, 2, missing, missing, missing, missing, missing, 6], 
[missing, missing, missing, missing, 1, missing, missing, missing, missing, 
 missing, 10], 
[missing, missing, missing, missing, 1, missing, missing, missing, 3, missing, 
 missing, missing, missing, missing, missing, missing, missing, missing, 
missing, missing, missing, missing, missing, missing, missing, missing, 
missing, missing, 3]]
end

Then start the julia REPL and type using Bug. Then when you exit the REPL (typing ^D for instance) you
see the bug. The bug does not appear if you paste the contents at the REPL or if you omit using Combinatorics. Weird, is not it?

After more fiddling I could reduce the file Bug.jl to load to the following:

module Bug
using Combinatorics
v=[missing, 2, missing, 6, missing, missing, missing, missing, 
missing, missing, missing, missing, missing, 6]
end
1 Like

I couldn’t reproduce on OSX, but this kind of example is super valuable. I would post it as an issue, along with the st --manifest and versioninfo() outputs.

2 Likes

what kind of command is st --manifest? Where do you type it?
Here is

julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

At the REPL, type ] st --manifest

OK. Here it is:

(v1.0) pkg> st --manifest
    Status `~/.julia/environments/v1.0/Manifest.toml`
  [6e4b80f9] BenchmarkTools v0.4.0
  [861a8166] Combinatorics v0.7.0
  [682c06a0] JSON v0.19.0
  [c03570c3] Memoize v0.3.0
  [bac558e1] OrderedCollections v0.1.0
  [f27b6e38] Polynomials v0.5.0
  [27ebfcd6] Primes v0.4.0
  [295af30f] Revise v0.7.5
  [2a0f44e3] Base64 
  [ade2ca70] Dates 
  [8ba89e20] Distributed 
  [7b1f6079] FileWatching 
  [b77e0a4c] InteractiveUtils 
  [76f85450] LibGit2 
  [8f399da3] Libdl 
  [37e2e46d] LinearAlgebra 
  [56ddb016] Logging 
  [d6f4376e] Markdown 
  [a63ad114] Mmap 
  [44cfe95a] Pkg 
  [de0858da] Printf 
  [3fa0cd96] REPL 
  [9a3f8284] Random 
  [ea8e919c] SHA 
  [9e88b42a] Serialization 
  [1a1011a3] SharedArrays 
  [6462fe0b] Sockets 
  [2f01184e] SparseArrays 
  [10745b16] Statistics 
  [8dfed614] Test 
  [cf7118a7] UUIDs 
  [4ec0a83e] Unicode

I tried with this with the 1.1.0 nightly build, and there is no problem if I just do using Bug.

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0-DEV.127 (2018-08-27)
 _/ |\__'_|_|_|\__'_|  |  Commit 3ab56f19a8 (5 days old master)
|__/                   |

julia> push!(LOAD_PATH, ".")
4-element Array{String,1}:
 "@"      
 "@v#.#"  
 "@stdlib"
 "."      

julia> using Bug

julia> exit()

But, if I first include the file before using Bug, then I got this and Julia coredumps:

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0-DEV.127 (2018-08-27)
 _/ |\__'_|_|_|\__'_|  |  Commit 3ab56f19a8 (5 days old master)
|__/                   |

julia> push!(LOAD_PATH, ".")
4-element Array{String,1}:
 "@"      
 "@v#.#"  
 "@stdlib"
 "."      

julia> include("Bug.jl")
Main.Bug

julia> using Bug

signal (11): Segmentation fault
in expression starting at no file:0
jl_gc_pool_alloc at /buildworker/worker/package_linux64/build/src/gc.c:962
jl_gc_alloc_ at /buildworker/worker/package_linux64/build/src/julia_internal.h:274 [inlined]
jl_gc_alloc at /buildworker/worker/package_linux64/build/src/gc.c:2671
_new_array_ at /buildworker/worker/package_linux64/build/src/array.c:100 [inlined]
_new_array at /buildworker/worker/package_linux64/build/src/array.c:157 [inlined]
jl_alloc_array_1d at /buildworker/worker/package_linux64/build/src/array.c:417
Type at ./boot.jl:394 [inlined]
Type at ./boot.jl:403 [inlined]
fill at ./array.jl:418 [inlined]
fill at ./array.jl:416 [inlined]
domsort_ssa! at ./compiler/ssair/slot2ssa.jl:434
construct_ssa! at ./compiler/ssair/slot2ssa.jl:869
just_construct_ssa at ./compiler/ssair/driver.jl:109
run_passes at ./compiler/ssair/driver.jl:114
optimize at ./compiler/optimize.jl:162
typeinf at ./compiler/typeinfer.jl:35
typeinf_ext at ./compiler/typeinfer.jl:567
typeinf_ext at ./compiler/typeinfer.jl:604
jfptr_typeinf_ext_1.clone_1 at /home/djia/Software/julia-3ab56f19a8/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2196
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1557 [inlined]
jl_apply_with_saved_exception_state at /buildworker/worker/package_linux64/build/src/rtutils.c:257
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:275
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1796 [inlined]
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1840
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2196
_include_from_serialized at ./loading.jl:630
macro expansion at ./logging.jl:312 [inlined]
_require_search_from_serialized at ./loading.jl:701
_require at ./loading.jl:934
require at ./loading.jl:855
macro expansion at ./logging.jl:311 [inlined]
require at ./loading.jl:837
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2196
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1557 [inlined]
call_require at /buildworker/worker/package_linux64/build/src/toplevel.c:443 [inlined]
eval_import_path at /buildworker/worker/package_linux64/build/src/toplevel.c:478
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:638
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/builtins.c:622
eval at ./boot.jl:319
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2196
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:259
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2196
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1557 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:271
unknown function (ip: 0xffffffffffffffff)
Allocations: 1806441 (Pool: 1805999; Big: 442); GC: 3
Segmentation fault (core dumped)

I opened an issue #28998 so please redirect all comments to there. Thanks!

2 Likes

Here is the link:
https://github.com/JuliaLang/julia/issues/28998

1 Like