Project

General

Profile

Actions

Bug #3925

closed

setting Tempfile/StringIO to $std* before startup causes [BUG] Segmentation fault

Added by arton (Akio Tajima) about 14 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-mswin32_100]
Backport:
[ruby-dev:42356]

Description

=begin
$stdout, in, errにTempfileやStringIOをセットするライブラリを-rで読み込むと[BUG]となります。
例)
#d.rb
require 'stringio'
$stdout = StringIO.new
#---------------------------------
を作って

$ruby -r./d -e 'puts "hello"'
-e: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-mswin32_100]

-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:00122c d:00122c TOP

以下のパッチで少なくともTempfileは救えます。StringIOについてはset_encodingが無いので無理ですが。

--- io.c.org Sat Jul 24 19:38:33 2010
+++ io.c Mon Oct 11 03:47:30 2010
@@ -8652,9 +8652,9 @@ rb_stdio_set_default_encoding(void)
extern VALUE rb_stdin, rb_stdout, rb_stderr;
VALUE val = Qnil;

  • rb_io_set_encoding(1, &val, rb_stdin);
  • rb_io_set_encoding(1, &val, rb_stdout);
  • rb_io_set_encoding(1, &val, rb_stderr);
  • rb_funcall3(rb_stdin, rb_intern("set_encoding"), 1, &val);
  • rb_funcall3(rb_stdout, rb_intern("set_encoding"), 1, &val);
  • rb_funcall3(rb_stderr, rb_intern("set_encoding"), 1, &val);
    }

/*

-rで読み込むと自動的にデバッガ付き状態で動く(ターゲットにrequireを埋め込みたくない)ライブラリを開発していて気づきました。
=end

Actions #1

Updated by naruse (Yui NARUSE) about 14 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r29435.
Akio, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0