Strange segfault

question
bug
#1

Hi,

I have a strange segmentation fault with the next code:

using BioAlignments
using MIToS.MSA
using MIToS.SIFTS
using MIToS.PDB
using StatsPlots

filename = "/home/zea/.julia/dev/MIToS/test/data/modeller.pir.gz";
msa = read(filename, PIR, generatemapping=true);
pid = percentidentity(msa);
@show pid;

The strange things are:

  • I only get a segfault if all the using lines are included. It works well if I comment out one of the unused using statements.
  • It works well in Jupyter/Juno/REPL, but I get a segfault in the percentidentity call when I use the code as a script:

I know that the segmentation fault is related to the PairwiseListMatrix constructor [https://github.com/diegozea/PairwiseListMatrices.jl/blob/master/src/pairwiselistmatrix.jl#L12], but I don’t understand why it fails and why it only fails in scripts where multiple using statements are present. The following also gives a segfault:

using BioAlignments
using MIToS.PDB
using StatsPlots
using PairwiseListMatrices

PairwiseListMatrix{Float64, false, Vector{Float64}}([0.5], [0.2, 0.2], 2)

The segfault is:

signal (11): Segmentation fault
in expression starting at /home/zea/Desktop/test_julia/small.jl:6
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1176
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:323
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:411
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:362 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:773
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:885
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fd5e057986f)
unknown function (ip: 0x3)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:894
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:764
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:883
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:826
include at ./boot.jl:326 [inlined]
include_relative at ./loading.jl:1038
include at ./sysimg.jl:29
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
exec_options at ./client.jl:267
_start at ./client.jl:436
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
unknown function (ip: 0x40191d)
unknown function (ip: 0x401523)
__libc_start_main at /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
unknown function (ip: 0x4015c4)
Allocations: 29060960 (Pool: 29055833; Big: 5127); GC: 62
/bin/bash: line 1:  5786 Segmentation fault      (core dumped) ( julia 'small.jl' )

I’ve Julia 1.1 in Ubuntu 18.04:

Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2609 v3 @ 1.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)
Environment:
  JULIA_EDITOR = atom  -a
  JULIA_NUM_THREADS = 6
  [c7e460c6] ArgParse v0.6.2
  [c52e3926] Atom v0.8.4
  [99c8bb3a] Bio3DView v0.1.0
  [00701ae9] BioAlignments v1.0.0
  [a93c6f00] DataFrames v0.17.1
  [864edb3b] DataStructures v0.15.0
  [f7f18e0c] GLFW v2.3.0
  [c27321d9] Glob v1.2.0
  [7073ff75] IJulia v1.18.0
  [e5e0dc1b] Juno v0.7.0
  [51bafb47] MIToS v2.3.3+ [`~/.julia/dev/MIToS`]
  [ee78f7c6] Makie v0.9.3
  [66fc600b] ModernGL v1.0.0
  [f9da4da7] PairwiseListMatrices v0.7.0
  [be69cb46] PdbTool v0.1.0+ #master (https://github.com/christophfeinauer/PdbTool.jl.git)
  [91a5bcdd] Plots v0.24.0
  [ce6b1742] RDatasets v0.6.1
  [295af30f] Revise v2.1.0
  [91ba51fb] SixelTerm v0.0.0 #master (https://github.com/tshort/SixelTerm.jl.git)
  [b85f4697] SoftGlobalScope v1.0.10
  [f3b207a7] StatsPlots v0.10.2

Any help you can give will be greatly appreciated.

Best regards,

#2

The segfault in the last example is solved by changing the constructor signature from:

    function PairwiseListMatrix{T,diagonal,VT}(list::AbstractVector{T},
                                               diag::AbstractVector{T},
                                               N::Int) where {T,diagonal,VT}

To:

    function PairwiseListMatrix{T,diagonal,VT}(list::VT,
                                               diag::VT,
                                               N::Int) where {T,diagonal,VT}

However, the first script still segfaults in percentidentity.

#3

After the previous modification, the following code still fails when it runs as a script:

using BioAlignments
using MIToS.MSA
using MIToS.SIFTS
using MIToS.PDB
using StatsPlots

filename = "/home/zea/.julia/dev/MIToS/test/data/modeller.pir.gz";
msa = read(filename, PIR, generatemapping=true);
pid = percentidentity(msa);
@show pid;
signal (11): Segmentation fault
in expression starting at /home/zea/Desktop/test_julia/templates_summary.jl:9
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1176
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
emit_invoke at /buildworker/worker/package_linux64/build/src/codegen.cpp:3145
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:3948
emit_ssaval_assign at /buildworker/worker/package_linux64/build/src/codegen.cpp:3662
emit_function at /buildworker/worker/package_linux64/build/src/codegen.cpp:3854
jl_compile_linfo at /buildworker/worker/package_linux64/build/src/codegen.cpp:1144
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:323
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:411
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:362 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:773
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:885
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7fe33895d2cf)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:894
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:764
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:713
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:883
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:826
include at ./boot.jl:326 [inlined]
include_relative at ./loading.jl:1038
include at ./sysimg.jl:29
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
exec_options at ./client.jl:267
_start at ./client.jl:436
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
unknown function (ip: 0x40191d)
unknown function (ip: 0x401523)
__libc_start_main at /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
unknown function (ip: 0x4015c4)
Allocations: 39405729 (Pool: 39399663; Big: 6066); GC: 86
/bin/bash: line 1:  8146 Segmentation fault      (core dumped) ( julia 'templates_summary.jl' )
#4

How can I now exactly what is causing the segfault?

#5

It runs well with julia --inline=no