JuliaML / LIBSVM.jl

LIBSVM bindings for Julia
Other
88 stars 35 forks source link

Segfault in svmpredict with @btime #49

Closed laborg closed 4 years ago

laborg commented 4 years ago

I'm running into a segfault when trying to benchmark svmpredict. My config:

Following MWE (taken from the unit tests of LIBSVM):

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using DelimitedFiles, LIBSVM, BenchmarkTools

julia> iris = readdlm(joinpath(dirname(@__FILE__), "iris.csv"), ',')

julia> labels = iris[:, 5];

julia> tinstances = convert(Matrix{Float64}, iris[:, 1:4]');

julia> model = svmtrain(tinstances[:, 1:2:end], labels[1:2:end]; verbose=false);

julia> @btime (class, decvalues) = svmpredict(model, tinstances[:, 2:2:end])
59.607 μs (16 allocations: 15.50 KiB)
(Any["setosa", "setosa", "setosa", "setosa", "setosa", "setosa", "setosa", "setosa", "setosa", "setosa"  …  "virginica", "versicolor", "virginica", "virginica", "virginica", "virginica", "virginica", "virginica", "virginica", "virginica"], [1.0795373127217927 1.076285347307982 … -0.8977486201494332 -0.9364766069276098; 1.1004210525961036 1.0767138900115194 … -1.0382989966396097 -1.0734485152396267; 0.26369235850072076 0.2543044167727957 … -0.5718494685608961 -0.31568093085243765])

julia> @btime (class, decvalues) = svmpredict(model, tinstances[:, 2:2:end])

signal (11): Segmentation fault
in expression starting at REPL[6]:1
_ZN6Kernel10k_functionEPK8svm_nodeS2_RK13svm_parameter at /home/gerhard/.julia/packages/LIBSVM/5Z99T/src/../deps/libsvm.so.2 (unknown line)
unknown function (ip: 0x7efdf43d386f)
Allocations: 14234478 (Pool: 13915011; Big: 319467); GC: 58
Segmentation fault (core dumped)

Sometimes I've to run the last line a couple of times to get the segfault. Anything else I can test?

laborg commented 4 years ago

Starting julia with --inline=no prevents the segfault...

laborg commented 4 years ago

Closing this because I can't reproduce this error with Julia 1.4.2 and the latest LIBSVM (0.4.0) anymore.