Project

General

Profile

Bug #5803

closed output and Readline.readline dumps core

Added by no6v (Nobuhiro IMAI) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2011-12-23 trunk 34110) [x86_64-linux]
Backport:
[ruby-dev:45043]

Description

=begin
libreadline 側の問題だと思うのですが、Readline.output= に指定した IO をクローズした後
Readline.readline で補完するとコアダンプしました。
"##\t" のところを色々変えてみるとコアダンプしたりしなかったりします。

$ cat readline_test.rb
require "readline"

IO.pipe do |r, w|
Readline.input = r
Readline.output = w
(w << "##\t").close
Readline.readline
end
$ ruby -v readline_test.rb
ruby 2.0.0dev (2011-12-23 trunk 34110) [x86_64-linux]
*** glibc detected *** ruby: free(): invalid pointer: 0x0000000001470503 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x72656)[0x7fb8f5f23656]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7fb8f5f2838c]
/lib/x86_64-linux-gnu/libc.so.6(IO_free_backup_area+0x19)[0x7fb8f5f21ce9]
/lib/x86_64-linux-gnu/libc.so.6(_IO_file_overflow+0x20e)[0x7fb8f5f200fe]
/lib/x86_64-linux-gnu/libc.so.6(_IO_file_xsputn+0x6d)[0x7fb8f5f1f50d]
/lib/x86_64-linux-gnu/libc.so.6(fwrite+0x10d)[0x7fb8f5f159ed]
/lib/x86_64-linux-gnu/libreadline.so.6(+0x26afb)[0x7fb8f5685afb]
/lib/x86_64-linux-gnu/libreadline.so.6(rl_redisplay+0x5d1)[0x7fb8f56866b1]
/lib/x86_64-linux-gnu/libreadline.so.6(_rl_internal_char_cleanup+0x89)[0x7fb8f5675599]
/lib/x86_64-linux-gnu/libreadline.so.6(readline_internal_char+0xc5)[0x7fb8f5675e05]
/lib/x86_64-linux-gnu/libreadline.so.6(readline+0x55)[0x7fb8f56762e5]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(rb_protect+0xda)[0x7fb8f6d7c7ea]
/home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/readline.so(+0x384b)[0x7fb8f58a984b]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x17558a)[0x7fb8f6e8b58a]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x16ae29)[0x7fb8f6e80e29]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x17177a)[0x7fb8f6e8777a]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(rb_yield+0x47)[0x7fb8f6e8cf37]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(rb_ensure+0xbb)[0x7fb8f6d7ca2b]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x91805)[0x7fb8f6da7805]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x17558a)[0x7fb8f6e8b58a]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x16ae29)[0x7fb8f6e80e29]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x17177a)[0x7fb8f6e8777a]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(rb_iseq_eval_main+0xa6)[0x7fb8f6e8da86]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(+0x650c2)[0x7fb8f6d7b0c2]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(ruby_exec_node+0x1d)[0x7fb8f6d7c15d]
/home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9(ruby_run_node+0x1e)[0x7fb8f6d7e18e]
ruby[0x40089b]
/lib/x86_64-linux-gnu/libc.so.6(
_libc_start_main+0xfd)[0x7fb8f5ecfead]
ruby[0x4008c9]
======= Memory map: ========
00400000-00401000 r-xp 00000000 08:01 814859 /home/nov/.rvm/rubies/ruby-head/bin/ruby
00600000-00601000 rw-p 00000000 08:01 814859 /home/nov/.rvm/rubies/ruby-head/bin/ruby
01209000-014a6000 rw-p 00000000 00:00 0 [heap]
7fb8f0000000-7fb8f0021000 rw-p 00000000 00:00 0
7fb8f0021000-7fb8f4000000 ---p 00000000 00:00 0
7fb8f4fff000-7fb8f5014000 r-xp 00000000 08:01 1896664 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb8f5014000-7fb8f5214000 ---p 00015000 08:01 1896664 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb8f5214000-7fb8f5215000 rw-p 00015000 08:01 1896664 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb8f5215000-7fb8f5238000 r-xp 00000000 08:01 429937 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fb8f5238000-7fb8f5438000 ---p 00023000 08:01 429937 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fb8f5438000-7fb8f543c000 r--p 00023000 08:01 429937 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fb8f543c000-7fb8f543d000 rw-p 00027000 08:01 429937 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7fb8f543d000-7fb8f545e000 r-xp 00000000 08:01 176556 /lib/x86_64-linux-gnu/libncurses.so.5.9
7fb8f545e000-7fb8f565d000 ---p 00021000 08:01 176556 /lib/x86_64-linux-gnu/libncurses.so.5.9
7fb8f565d000-7fb8f565e000 r--p 00020000 08:01 176556 /lib/x86_64-linux-gnu/libncurses.so.5.9
7fb8f565e000-7fb8f565f000 rw-p 00021000 08:01 176556 /lib/x86_64-linux-gnu/libncurses.so.5.9
7fb8f565f000-7fb8f569c000 r-xp 00000000 08:01 1745771 /lib/x86_64-linux-gnu/libreadline.so.6.2
7fb8f569c000-7fb8f589c000 ---p 0003d000 08:01 1745771 /lib/x86_64-linux-gnu/libreadline.so.6.2
7fb8f589c000-7fb8f589e000 r--p 0003d000 08:01 1745771 /lib/x86_64-linux-gnu/libreadline.so.6.2
7fb8f589e000-7fb8f58a4000 rw-p 0003f000 08:01 1745771 /lib/x86_64-linux-gnu/libreadline.so.6.2
7fb8f58a4000-7fb8f58a6000 rw-p 00000000 00:00 0
7fb8f58a6000-7fb8f58ac000 r-xp 00000000 08:01 348988 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/readline.so
7fb8f58ac000-7fb8f5aab000 ---p 00006000 08:01 348988 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/readline.so
7fb8f5aab000-7fb8f5aac000 rw-p 00005000 08:01 348988 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/readline.so
7fb8f5aac000-7fb8f5aae000 r-xp 00000000 08:01 2728914 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fb8f5aae000-7fb8f5cae000 ---p 00002000 08:01 2728914 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fb8f5cae000-7fb8f5caf000 rw-p 00002000 08:01 2728914 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fb8f5caf000-7fb8f5cb1000 r-xp 00000000 08:01 2728873 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fb8f5cb1000-7fb8f5eb0000 ---p 00002000 08:01 2728873 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fb8f5eb0000-7fb8f5eb1000 rw-p 00001000 08:01 2728873 /home/nov/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fb8f5eb1000-7fb8f602b000 r-xp 00000000 08:01 1591094 /lib/x86_64-linux-gnu/libc-2.13.so
7fb8f602b000-7fb8f622b000 ---p 0017a000 08:01 1591094 /lib/x86_64-linux-gnu/libc-2.13.so
7fb8f622b000-7fb8f622f000 r--p 0017a000 08:01 1591094 /lib/x86_64-linux-gnu/libc-2.13.so
7fb8f622f000-7fb8f6230000 rw-p 0017e000 08:01 1591094 /lib/x86_64-linux-gnu/libc-2.13.so
7fb8f6230000-7fb8f6235000 rw-p 00000000 00:00 0
7fb8f6235000-7fb8f62b6000 r-xp 00000000 08:01 1591078 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8f62b6000-7fb8f64b5000 ---p 00081000 08:01 1591078 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8f64b5000-7fb8f64b6000 r--p 00080000 08:01 1591078 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8f64b6000-7fb8f64b7000 rw-p 00081000 08:01 1591078 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8f64b7000-7fb8f64bf000 r-xp 00000000 08:01 1591090 /lib/x86_64-linux-gnu/libcrypt-2.13.so
7fb8f64bf000-7fb8f66be000 ---p 00008000 08:01 1591090 /lib/x86_64-linux-gnu/libcrypt-2.13.so
7fb8f66be000-7fb8f66bf000 r--p 00007000 08:01 1591090 /lib/x86_64-linux-gnu/libcrypt-2.13.so
7fb8f66bf000-7fb8f66c0000 rw-p 00008000 08:01 1591090 /lib/x86_64-linux-gnu/libcrypt-2.13.so
7fb8f66c0000-7fb8f66ee000 rw-p 00000000 00:00 0
7fb8f66ee000-7fb8f66f0000 r-xp 00000000 08:01 1591089 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb8f66f0000-7fb8f68f0000 ---p 00002000 08:01 1591089 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb8f68f0000-7fb8f68f1000 r--p 00002000 08:01 1591089 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb8f68f1000-7fb8f68f2000 rw-p 00003000 08:01 1591089 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb8f68f2000-7fb8f68f9000 r-xp 00000000 08:01 1591093 /lib/x86_64-linux-gnu/librt-2.13.so
7fb8f68f9000-7fb8f6af8000 ---p 00007000 08:01 1591093 /lib/x86_64-linux-gnu/librt-2.13.so
7fb8f6af8000-7fb8f6af9000 r--p 00006000 08:01 1591093 /lib/x86_64-linux-gnu/librt-2.13.so
7fb8f6af9000-7fb8f6afa000 rw-p 00007000 08:01 1591093 /lib/x86_64-linux-gnu/librt-2.13.so
7fb8f6afa000-7fb8f6b11000 r-xp 00000000 08:01 1591081 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb8f6b11000-7fb8f6d10000 ---p 00017000 08:01 1591081 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb8f6d10000-7fb8f6d11000 r--p 00016000 08:01 1591081 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb8f6d11000-7fb8f6d12000 rw-p 00017000 08:01 1591081 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb8f6d12000-7fb8f6d16000 rw-p 00000000 00:00 0
7fb8f6d16000-7fb8f6f2f000 r-xp 00000000 08:01 348944 /home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9.1
7fb8f6f2f000-7fb8f712e000 ---p 00219000 08:01 348944 /home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9.1
7fb8f712e000-7fb8f7136000 rw-p 00218000 08:01 348944 /home/nov/.rvm/rubies/ruby-head/lib/libruby.so.1.9.1
7fb8f7136000-7fb8f7153000 rw-p 00000000 00:00 0
7fb8f7153000-7fb8f7172000 r-xp 00000000 08:01 1591080 /lib/x86_64-linux-gnu/ld-2.13.so
7fb8f7250000-7fb8f7356000 rw-p 00000000 00:00 0
7fb8f736a000-7fb8f736c000 rw-p 00000000 00:00 0
7fb8f736c000-7fb8f736d000 ---p 00000000 00:00 0
7fb8f736d000-7fb8f7372000 rw-p 00000000 00:00 0
7fb8f7372000-7fb8f7373000 r--p 0001f000 08:01 1591080 /lib/x86_64-linux-gnu/ld-2.13.so
7fb8f7373000-7fb8f7374000 rw-p 00020000 08:01 1591080 /lib/x86_64-linux-gnu/ld-2.13.so
7fb8f7374000-7fb8f7375000 rw-p 00000000 00:00 0
7fff5517e000-7fff5519f000 rw-p 00000000 00:00 0 [stack]
7fff551ff000-7fff55200000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
$ gdb ruby core
GNU gdb (GDB) 7.3-debian
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /home/nov/.rvm/rubies/ruby-head/bin/ruby...done.
[New LWP 14888]
[New LWP 14889]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Core was generated by `ruby -v readline_test.rb'.
Program terminated with signal 6, Aborted.
#0 0x00007fb8f5ee3405 in *GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) bt
#0 0x00007fb8f5ee3405 in *
GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007fb8f5ee6680 in *GI_abort () at abort.c:92
#2 0x00007fb8f5f19e0b in __libc_message (do_abort=, fmt=) at ../sysdeps/unix/sysv/linux/libc_fatal.c:189
#3 0x00007fb8f5f23656 in malloc_printerr (action=3, str=0x7fb8f5ff730a "free(): invalid pointer", ptr=) at malloc.c:6283
#4 0x00007fb8f5f2838c in *
GI___libc_free (mem=) at malloc.c:3738
#5 0x00007fb8f5f21ce9 in _IO_free_backup_area (fp=0x1470480) at genops.c:214
#6 0x00007fb8f5f200fe in _IO_new_file_overflow (f=0x1470480, ch=-1) at fileops.c:863
#7 0x00007fb8f5f1f50d in _IO_new_file_xsputn (f=0x1470480, data=0x14882d1, n=1) at fileops.c:1358
#8 0x00007fb8f5f159ed in _IO_fwrite (buf=0x0, size=1, count=1, fp=0x1470480) at iofwrite.c:45
#9 0x00007fb8f5685afb in update_line (old=0x1487ec0 "#", new=0x14882d0 "##", current_line=0, omax=, nmax=1, inv_botlin=0)
at /build/buildd-readline6_6.2-8-amd64-0uxEBv/readline6-6.2/display.c:1658
#10 0x00007fb8f56866b1 in rl_redisplay () at /build/buildd-readline6_6.2-8-amd64-0uxEBv/readline6-6.2/display.c:976
#11 0x00007fb8f5675599 in _rl_internal_char_cleanup () at /build/buildd-readline6_6.2-8-amd64-0uxEBv/readline6-6.2/readline.c:465
#12 0x00007fb8f5675e05 in readline_internal_char () at /build/buildd-readline6_6.2-8-amd64-0uxEBv/readline6-6.2/readline.c:561
#13 0x00007fb8f56762e5 in readline_internal_charloop () at /build/buildd-readline6_6.2-8-amd64-0uxEBv/readline6-6.2/readline.c:579
#14 readline_internal () at /build/buildd-readline6_6.2-8-amd64-0uxEBv/readline6-6.2/readline.c:593
#15 readline (prompt=) at /build/buildd-readline6_6.2-8-amd64-0uxEBv/readline6-6.2/readline.c:342
#16 0x00007fb8f6d7c7ea in rb_protect (proc=0x7fb8f58a98e0 , data=0, state=0x7fff5519bfdc) at eval.c:709
#17 0x00007fb8f58a984b in readline_readline (argc=, argv=0x7fb8f7250090, self=) at readline.c:379
#18 0x00007fb8f6e8b58a in vm_call_cfunc (me=0x146d040, blockptr=0x0, recv=, num=, reg_cfp=0x7fb8f734fe00,
th=0x1209610) at vm_insnhelper.c:404
#19 vm_call_method (th=0x1209610, cfp=0x7fb8f734fe00, num=, blockptr=0x0, flag=, id=,
me=0x146d040, recv=21350360) at vm_insnhelper.c:534
#20 0x00007fb8f6e80e29 in vm_exec_core (th=, initial=) at insns.def:1015
#21 0x00007fb8f6e8777a in vm_exec (th=0x1209610) at vm.c:1217
#22 0x00007fb8f6e8cf37 in vm_yield (th=, argv=0x7fff5519c308, argc=1) at vm.c:636
#23 rb_yield_0 (argv=0x7fff5519c308, argc=1) at vm_eval.c:775
#24 rb_yield (val=21348760) at vm_eval.c:785
#25 0x00007fb8f6d7ca2b in rb_ensure (b_proc=0x7fb8f6e8cef0 , data1=21348760, e_proc=0x7fb8f6d98700 ,
data2=140734621140096) at eval.c:734
---Type to continue, or q to quit---
#26 0x00007fb8f6da7805 in rb_io_s_pipe (argc=, argv=, klass=) at io.c:8863
#27 0x00007fb8f6e8b58a in vm_call_cfunc (me=0x12e3440, blockptr=0x7fb8f734ff30, recv=, num=,
reg_cfp=0x7fb8f734ff08, th=0x1209610) at vm_insnhelper.c:404
#28 vm_call_method (th=0x1209610, cfp=0x7fb8f734ff08, num=, blockptr=0x7fb8f734ff30, flag=,
id=, me=0x12e3440, recv=19267360) at vm_insnhelper.c:534
#29 0x00007fb8f6e80e29 in vm_exec_core (th=, initial=) at insns.def:1015
#30 0x00007fb8f6e8777a in vm_exec (th=0x1209610) at vm.c:1217
#31 0x00007fb8f6e8da86 in rb_iseq_eval_main (iseqval=21353000) at vm.c:1456
#32 0x00007fb8f6d7b0c2 in ruby_exec_internal (n=0x145d228) at eval.c:204
#33 0x00007fb8f6d7c15d in ruby_exec_node (n=0x145d228) at eval.c:251
#34 0x00007fb8f6d7e18e in ruby_run_node (n=0x145d228) at eval.c:244
#35 0x000000000040089b in main (argc=3, argv=0x7fff5519ca78) at main.c:38
=end

Associated revisions

Revision 1dec79c3
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34116
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

Revision 34116
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

Revision 34116
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

Revision 34116
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

Revision 34116
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

Revision 34116
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

Revision 381821de
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) 34116:

    * ext/readline/readline.c (readline_readline): check if outstream
      is closed to get rid of a bug of readline 6.  [ruby-dev:45043]
      [Bug #5803]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

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

This issue was solved with changeset r34116.
Nobuhiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803]

Also available in: Atom PDF