From affd84d884cb05c7fc6e87c52999858bbf6e8d5b Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Wed, 27 Apr 2016 12:27:12 +0300 Subject: [PATCH] ruby: fix sporadic segfaults during the garbage collection rb_sigar_new does not initialize rb_sigar_t->logger, as a result ruby runtime garbage collection routines sometimes fail either with a segfault or an assertion failure: $ cat test2.rb require 'sigar' 100.times do GC.disable sigars = [] 100.times do sigar = Sigar.new sigars << sigar end GC.enable GC.start sleep 2 end $ ruby test2.rb /home/asheplyakov/tmp/test2.rb:11: [BUG] rb_gc_mark(): unknown data type 0x0(0x7fbff5cc07c8) non object ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux] [skipped] Initialize rb_sigar_t->logger to avoid the problem. Fixes github issue #79 --- bindings/ruby/rbsigar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/ruby/rbsigar.c b/bindings/ruby/rbsigar.c index 33755c6ae..0c862c51a 100644 --- a/bindings/ruby/rbsigar.c +++ b/bindings/ruby/rbsigar.c @@ -162,6 +162,7 @@ static VALUE rb_sigar_new(VALUE module) { rb_sigar_t *rbsigar; rbsigar = ALLOC(rb_sigar_t); + rbsigar->logger = Qnil; sigar_open(&(rbsigar->sigar)); return Data_Wrap_Struct(module, rb_sigar_mark, rb_sigar_close, rbsigar); }