Project

General

Profile

Actions

Bug #6232

closed

Ruby : Segmentation fault on Readline.refresh_line after screen resize.

Added by rubysubmit (Ruby Submit) over 12 years ago. Updated almost 10 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.2p290
[ruby-core:43957]

Description

Repro

require readline

Readline.set_screen_size(40, 80)
Readline.refresh_line

buf = Readline.readline
./test_readline.rb 
./test_readline.rb:10: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18) [i686-linux]

-- control frame ----------
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC  :refresh_line
c:0003 p:0047 s:0007 b:0007 l:0000c4 d:001850 EVAL   ./test_readline.rb:10
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0000c4 d:0000c4 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
./test_readline.rb:10:in `<main>'
./test_readline.rb:10:in `refresh_line'

-- C level backtrace information -------------------------------------------
/testing/bin/ruby(rb_vm_bugreport+0xa5) [0x8161a65]
/testing/bin/ruby() [0x81a0ae9]
/testing/bin/ruby(rb_bug+0x28) [0x81a0b98]
/testing/bin/ruby() [0x80f39d8]
[0x4b1410]
/lib/libreadline.so.5(_rl_output_character_function+0x29) [0xb557b9]
/lib/libncurses.so.5(tputs+0xe1) [0xf33191]
/lib/libreadline.so.5(_rl_clear_to_eol+0x3b) [0xb4d8bb]
/lib/libreadline.so.5(rl_refresh_line+0x43) [0xb57153]
/testing/lib/ruby/site_ruby/1.9.1/i686-linux/readline.so(+0x2b52) [0x54db52]
/testing/bin/ruby() [0x8152158]
/testing/bin/ruby() [0x81544d8]
/testing/bin/ruby() [0x815812e]
/testing/bin/ruby(rb_iseq_eval_main+0x1ce) [0x815850e]
/testing/bin/ruby() [0x805e4f2]
/testing/bin/ruby(ruby_run_node+0x32) [0x805fd12]
/testing/bin/ruby(main+0x5a) [0x805d72a]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x126bd6]
/testing/bin/ruby() [0x805d631]

Updated by mame (Yusuke Endoh) over 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to kouji (Kouji Takao)

Thank you for your report!
I could reproduce.
I assign this to the maintainer of readline.

--
Yusuke Endoh

Updated by wanabe (_ wanabe) almost 10 years ago

It seems like GNU Readline behavior.
Readline.refresh_line calls rl_refresh_line(0, 0) -> rl_clear_to_eol(0) -> tputs (_rl_term_clreol, 1, _rl_output_character_function) -> _rl_output_character_function(c) -> putc (c, _rl_out_stream).
it causes SEGV because _rl_out_stream is NULL until called readline() or rl_initialize().
(ref. Readline-6.3 patch 8 http://git.savannah.gnu.org/cgit/readline.git/commit/?id=a73b98f779b388a5d0624e02e8bb187246e3e396)

To correct this, readline.so should (1) set _rl_out_stream with rl_initialize() or direct assignment (2) or raise an exception when Readline.refresh_line is called before Readline have been initialized (3) or in some other way.

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

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

Applied in changeset r49244.


readline.c: initialize before rl_refresh_line

  • ext/readline/readline.c (readline_s_refresh_line): initialize
    before rl_refresh_line(), as some function make the internal
    state non-clean but rl_refresh_line() does not re-initialize it.
    [ruby-core:43957] [Bug #6232]
Actions #4

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

  • Description updated (diff)
  • Backport set to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED

Updated by naruse (Yui NARUSE) almost 10 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE

ruby_2_2 r49299 merged revision(s) 49244.

Updated by usa (Usaku NAKAMURA) almost 10 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE to 2.0.0: DONE, 2.1: REQUIRED, 2.2: DONE

ruby_2_0_0 r49424 merged revision(s) 49244.

Updated by usa (Usaku NAKAMURA) almost 10 years ago

  • Backport changed from 2.0.0: DONE, 2.1: REQUIRED, 2.2: DONE to 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: DONE

... reverted r49424.
ruby_2_0_0 ss too far from trunk.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0