Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion crashes on a method having invalid name as UTF-8 #900

Open
pocke opened this issue Mar 13, 2024 · 0 comments
Open

Completion crashes on a method having invalid name as UTF-8 #900

pocke opened this issue Mar 13, 2024 · 0 comments

Comments

@pocke
Copy link
Member

pocke commented Mar 13, 2024

Description

IRB crashes with the following code:

irb(main):001> define_method("a\xff".force_encoding(Encoding::ASCII_8BIT)){}
=> :"a\xFF"
irb(main):002> a/Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb/completion.rb:184:in `encode': "\xFF" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb/completion.rb:184:in `block in completion_candidates'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb/completion.rb:184:in `map'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb/completion.rb:184:in `completion_candidates'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb/input-method.rb:251:in `block in initialize'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:1634:in `call_completion_proc_with_checking_args'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:533:in `call_completion_proc_with_checking_args'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:237:in `block in <class:Core>'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:588:in `instance_exec'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:588:in `call'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:623:in `call'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:776:in `update_each_dialog'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:652:in `block in render_dialog'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:650:in `map'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:650:in `render_dialog'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/line_editor.rb:500:in `rerender'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:351:in `block (3 levels) in inner_readline'
	from <internal:array>:52:in `each'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:349:in `block (2 levels) in inner_readline'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:424:in `block in read_io'
	from <internal:kernel>:191:in `loop'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:394:in `read_io'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:347:in `block in inner_readline'
	from <internal:kernel>:191:in `loop'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:345:in `inner_readline'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:273:in `block in readmultiline'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/ansi.rb:152:in `block in with_raw_input'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/ansi.rb:152:in `raw'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline/ansi.rb:152:in `with_raw_input'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/reline.rb:269:in `readmultiline'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/forwardable.rb:240:in `readmultiline'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb/input-method.rb:453:in `gets'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:1028:in `block in read_input'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:1316:in `signal_status'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:1026:in `read_input'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:1048:in `readmultiline'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:1075:in `block in each_top_level_statement'
	from <internal:kernel>:191:in `loop'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:1074:in `each_top_level_statement'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:996:in `eval_input'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:983:in `block in run'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:982:in `catch'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:982:in `run'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/lib/irb.rb:884:in `start'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/irb-1.11.2/exe/irb:9:in `<top (required)>'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/bin/irb:25:in `load'
	from /Users/kuwabara.masataka/.rbenv/versions/trunk/bin/irb:25:in `<main>'

Note that IRB crashes when I enter a to the second IRB prompt.

Result of irb_info

Please paste the result of irb_info command in IRB.

ex.)

irb(main):001> irb_info
Ruby version: 3.4.0
IRB version: irb 1.11.2 (2024-02-07)
InputMethod: RelineInputMethod with Reline 0.4.2
Completion: Autocomplete, RegexpCompletor
RUBY_PLATFORM: arm64-darwin21
East Asian Ambiguous Width: 1

Terminal Emulator

Terminal.app of macOS

Setting Files

No irbrc. I removed ~/.irbrc before testing it.


BTW, I encountered this problem on the HEAD of ruby/ruby, and also Ruby 3.1.

I think it is an extremely rare case because no one has defined a method with an invalid name as UTF-8, but I reported it just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant