Bugs: Browse | Submit New | Admin

[#26889] open4-0.9.6 segfault(ruby 1.8.7 p160)

Date:
2009-08-07 11:06
Priority:
3
Submitted By:
masakazu tojo (m-tojo)
Assigned To:
Nobody (None)
Category:
open4
State:
Open
Summary:
open4-0.9.6 segfault(ruby 1.8.7 p160)

Detailed description
The following ruby snippet causes a segmentation fault with ruby 1.8.7 p160 and open4-0.9.6. 

###File: open4_segfault.rb###
#! /usr/local/bin/ruby

require "rubygems"
require "open4"
loop {
  begin
    pid,stdin,stdout,stderr = Open4.popen4("cat")
  rescue Exception => err
    p err.message
    p err.class.to_s
    break
  end
#  stdin.puts("test")
#  stderr.
#  msg = stdout.read
#  p msg
  stdin.close
  stdout.close
  stderr.close
  Process.waitpid2(pid)
#  sleep 1
}



###result###
/usr/local/lib/ruby/rubygems/gems/gems/open4-0.9.6/lib/open4.rb:15: [BUG] Segmentation fault
ruby 1.8.7 (2009-04-08 patchlevel 160) [x86_64-linux]

###trace###
gdb --args ruby open4_segfault.rb
Starting program: /usr/local/bin/ruby open4_segfault.rb
[Thread debugging using libthread_db enabled]
[New Thread 0x2b440f2971b0 (LWP 27338)]

Program received signal SIGSEGV, Segmentation fault.
st_foreach (table=0x2bfde, func=0x42dcc0 <mark_entry>, arg=0) at st.c:484
484         for(i = 0; i < table->num_bins; i++) {

(gdb) backtrace
#0  st_foreach (table=0x2bfde, func=0x42dcc0 <mark_entry>, arg=0) at st.c:484
#1  0x000000000042dd91 in mark_locations_array (x=0x7fff35098eb0, n=2520) at gc.c:684
#2  0x000000000042df66 in garbage_collect () at gc.c:1468
#3  0x000000000042ea07 in rb_newobj () at gc.c:436
#4  0x0000000000486929 in ary_alloc (klass=180190) at array.c:104
#5  0x000000000048697e in ary_new (klass=180190, len=4381888) at array.c:119
#6  0x0000000000486d0e in rb_assoc_new (car=47508664852880, cdr=4381888) at array.c:226
#7  0x0000000000434cd1 in rb_io_s_pipe (klass=<value optimized out>) at io.c:5336
#8  0x000000000041b54a in rb_call0 (klass=47508665164040, recv=47508665164080, id=7801, oid=7801, argc=0, argv=0x0,
body=0x2b35791c5d98, flags=<value optimized out>) at eval.c:5906
#9  0x000000000041c258 in rb_call (klass=47508665164040, recv=47508665164080, mid=7801, argc=0, argv=0x0, scope=0,
self=47508672455840) at eval.c:6153
#10 0x0000000000416ebb in rb_eval (self=47508672455840, n=<value optimized out>) at eval.c:3494
#11 0x00000000004167af in rb_eval (self=47508672455840, n=<value optimized out>) at eval.c:3847
#12 0x0000000000416221 in rb_eval (self=47508672455840, n=<value optimized out>) at eval.c:3673
#13 0x000000000041bda0 in rb_call0 (klass=47508672454800, recv=47508672455840, id=10953, oid=<value optimized out>,
argc=0, argv=0x7fff3509a240, body=0x2b35798d12e0, flags=<value optimized out>) at eval.c:6057
#14 0x000000000041c258 in rb_call (klass=47508672454800, recv=47508672455840, mid=10953, argc=1, argv=0x7fff3509a240,
scope=0, self=47508665242280) at eval.c:6153
#15 0x0000000000416ebb in rb_eval (self=47508665242280, n=<value optimized out>) at eval.c:3494
#16 0x0000000000416ae2 in rb_eval (self=47508665242280, n=<value optimized out>) at eval.c:3282
#17 0x0000000000416221 in rb_eval (self=47508665242280, n=<value optimized out>) at eval.c:3673
#18 0x00000000004186a1 in rb_eval (self=47508665242280, n=<value optimized out>) at eval.c:3310
#19 0x000000000041a2b5 in rb_yield_0 (val=6, self=47508665242280, klass=0, flags=<value optimized out>, avalue=0)
at eval.c:5079
#20 0x0000000000424e47 in loop_i () at eval.c:5211
#21 0x0000000000410704 in rb_rescue2 (b_proc=0x424e30 <loop_i>, data1=0, r_proc=0, data2=0) at eval.c:5475
#22 0x00000000004108e0 in rb_f_loop () at eval.c:5236
#23 0x000000000041b54a in rb_call0 (klass=47508665252160, recv=47508665242280, id=4121, oid=4121, argc=0, argv=0x0,
body=0x2b35791d7b88, flags=<value optimized out>) at eval.c:5906
#24 0x000000000041c258 in rb_call (klass=47508665252160, recv=47508665242280, mid=4121, argc=0, argv=0x0, scope=1,
self=47508665242280) at eval.c:6153
#25 0x0000000000416ff3 in rb_eval (self=<value optimized out>, n=<value optimized out>) at eval.c:3509
#26 0x0000000000418fcf in rb_eval (self=47508665242280, n=<value optimized out>) at eval.c:3224
#27 0x00000000004279e9 in ruby_exec_internal () at eval.c:1643
#28 0x0000000000427a35 in ruby_exec () at eval.c:1663
#29 0x0000000000427a5f in ruby_run () at eval.c:1673
#30 0x000000000040ddc3 in main (argc=2, argv=0x7fff3509bfd8, envp=<value optimized out>) at main.c:48


###other condition###
Running with ruby 1.8.7 p72.
  A segfault doesn't cause.

Running under GC.disble.
  A segfault doesn't cause.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-04-09 18:09
Sender: Matthew Kent

Appears fixed in 

ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]

but does affect ruby 1.8.6 p399. 

I've requested a backport here 

http://redmine.ruby-lang.org/issues/show/3118

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item