[Bug #1129] IO.binread(Pathname(...)) dumps core

Bug #1129: IO.binread(Pathname(…)) dumps core
http://redmine.ruby-lang.org/issues/show/1129

e$B5/I<<Te(B: Sakuro OZAWA
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
ruby -v: ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]

Pathnamee$B$N%$%s%9%?%s%9$r0z?t$K$7$?$H$-!“e(B
IO.binreade$B$,%3%”$rEG$-$^$9!#e(B
IO.reade$B$OEG$-$^$;$s!#e(B

MacOS X Leopard 10.5.6e$B$Ne(BMacPortse$B$Ne(Bruby19
Ubuntu Linux 8.04(Low Price Intel
Architecture)e$B$G<+J,$G%3%s%Q%$%k$7$?$b$Ne(B
e$B$G3NG’!#e(B

% ruby -rpathname -e ‘puts IO.read(Pathname(“/etc/shells”))’

List of acceptable shells for chpass(1).

Ftpd will not allow users to connect who are not using

/bin/tcsh /bin/zsh

% ruby -rpathname -e ‘puts IO.binread(Pathname(“/etc/shells”))’
-e:1: [BUG] Bus Error
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]

– control frame ----------
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :binread
c:0003 p:0025 s:0007 b:0006 l:001b64 d:001dd4 EVAL -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001b64 d:001b64 TOP :47140

– Ruby level backtrace
information-----------------------------------------
-e:1:in binread' -e:1:in

– C level backtrace information

0x2f8e02 0 libruby.dylib 0x002f8e02
rb_vm_bugreport + 82
0x20e38c 1 libruby.dylib 0x0020e38c rb_warning +
444
0x20e3eb 2 libruby.dylib 0x0020e3eb rb_bug + 43
0x29f5ab 3 libruby.dylib 0x0029f5ab
rb_enable_interrupt + 75
0x95abe2bb 4 libSystem.B.dylib 0x95abe2bb _sigtramp

  • 43
    0xffffffff 5 ??? 0xffffffff 0x0 +
    4294967295
    0x22cdc4 6 libruby.dylib 0x0022cdc4
    rb_close_before_exec + 484
    0x23696f 7 libruby.dylib 0x0023696f
    rb_file_open_str + 4959
    0x236a4d 8 libruby.dylib 0x00236a4d
    rb_file_open_str + 5181
    0x2e4845 9 libruby.dylib 0x002e4845
    rb_iseq_compile + 1125
    0x2e92bd 10 libruby.dylib 0x002e92bd rb_funcall2
  • 1773
    0x2eba2b 11 libruby.dylib 0x002eba2b rb_funcall2
  • 11867
    0x2f0e1b 12 libruby.dylib 0x002f0e1b rb_funcall2
  • 33355
    0x2f102f 13 libruby.dylib 0x002f102f
    rb_iseq_eval_main + 159
    0x2114e9 14 libruby.dylib 0x002114e9
    ruby_exec_node + 169
    0x213b6e 15 libruby.dylib 0x00213b6e
    ruby_run_node + 94
    0x1fef 16 ruby 0x00001fef main + 95
    0x1f56 17 ruby 0x00001f56 start + 54
    0x4 18 ??? 0x00000004 0x0 + 4

[NOTE]
You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

zsh: abort (core dumped) ruby -rpathname -e ‘puts
IO.binread(Pathname(“/etc/shells”))’

e$B%A%1%C%He(B #1129 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r22121.

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