Project

General

Profile

Actions

Bug #7136

closed

1.9.3-p194 segfault with c-extension

Added by puchuu (Andrew Aladjev) about 12 years ago. Updated about 12 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Backport:
[ruby-core:47882]

Description

file extconf.rb:

require "mkmf"
create_makefile("variables")

file variables.c:

#include "ruby.h"

void Init_variables()
{
VALUE num, arr, str;

    num = INT2FIX ( 1024 );
    rb_define_variable ( "$ext_var_num", & num );
    
    str = rb_str_new2 ( "this is sparta!" );
    rb_define_variable ( "$ext_var_str", & str );

}

file ext.rb:

($LOAD_PATH <<
File.expand_path("../", FILE)
).uniq!

require "variables"

puts $ext_var_str
puts $ext_var_num

ruby extconf.rb && make clean && make && ruby ext.rb

this is sparta!
ext.rb:15: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :puts
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :puts
c:0003 p:0067 s:0006 b:0006 l:0003f8 d:0009c8 EVAL ext.rb:15
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0003f8 d:0003f8 TOP

-- Ruby level backtrace information ----------------------------------------
ext.rb:15:in <main>' ext.rb:15:in puts'
ext.rb:15:in `puts'

-- C level backtrace information -------------------------------------------
/usr/lib64/libruby19.so.1.9(+0x155ae6) [0x7fc3f5a3dae6]
/usr/lib64/libruby19.so.1.9(+0x59fd3) [0x7fc3f5941fd3]
/usr/lib64/libruby19.so.1.9(rb_bug+0xbb) [0x7fc3f594277b]
/usr/lib64/libruby19.so.1.9(+0xf72bf) [0x7fc3f59df2bf]
/lib64/libc.so.6(+0x37f80) [0x7fc3f5578f80]
/usr/lib64/libruby19.so.1.9(rb_io_puts+0x90) [0x7fc3f5966bd0]
/usr/lib64/libruby19.so.1.9(+0x14c192) [0x7fc3f5a34192]
/usr/lib64/libruby19.so.1.9(+0x14fb93) [0x7fc3f5a37b93]
/usr/lib64/libruby19.so.1.9(+0x145b69) [0x7fc3f5a2db69]
/usr/lib64/libruby19.so.1.9(+0x14b1c4) [0x7fc3f5a331c4]
/usr/lib64/libruby19.so.1.9(rb_iseq_eval_main+0xad) [0x7fc3f5a3a63d]
/usr/lib64/libruby19.so.1.9(+0x5d80a) [0x7fc3f594580a]
/usr/lib64/libruby19.so.1.9(ruby_exec_node+0x1d) [0x7fc3f59462ad]
/usr/lib64/libruby19.so.1.9(ruby_run_node+0x1e) [0x7fc3f5947d3e]
ruby() [0x40099b]
/lib64/libc.so.6(__libc_start_main+0xf5) [0x7fc3f55656c5]
ruby() [0x4009c9]

Updated by puchuu (Andrew Aladjev) about 12 years ago

there are commented code in ext.rb
ext.rb:15 - this is "puts $ext_var_num"

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Status changed from Open to Third Party's Issue

auto variables are disposed when the function exits.

Actions

Also available in: Atom PDF

Like0
Like0Like0