Setting kernel_type causes segfault
chrislo opened this issue · 2 comments
chrislo commented
Hi,
Using rb-libsvm (1.0.4), ruby 1.9.2p136 (x86_64-darwin10.5.0) the following code causes a segfault:
require 'libsvm'
# This library is namespaced.
problem = Libsvm::Problem.new
parameter = Libsvm::SvmParameter.new
parameter.cache_size = 1 # in megabytes
parameter.eps = 0.001
parameter.c = 10
parameter.kernel_type = 2
parameter.gamma = 0.0025
examples = [ [1,0,1], [-1,0,-1] ].map {|ary| Libsvm::Node.features(ary) }
labels = [1, -1]
problem.set_examples(labels, examples)
model = Libsvm::Model.train(problem, parameter)
pred = model.predict(Libsvm::Node.features(1, 1, 1))
puts "Example [1, 1, 1] - Predicted #{pred}"
The segfault message reads
Example [1, 1, 1] - Predicted 1.0
lib/test_params.rb: [BUG] Segmentation fault
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.5.0]
-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:0014f8 d:0014f8 TOP
---------------------------
-- C level backtrace information -------------------------------------------
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Abort trap
The code runs fine if I comment out the parameter.kernel_type = 2
line.
Any ideas?
chrislo commented
Thank you for fixing so quickly. This works fine now!
neovintage commented
I'll push a new point release here in a moment.