Project

General

Profile

Bug #5921

SEGV caused by Encoding.compatible? "abc", :abc

Added by brixen (Brian Shirai) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
Backport:
[ruby-core:42204]

Description

Calling Encoding.compatible? with a String and Symbol causes a SEGV.

Calling with two Symbols, a Symbol and Regexp, or a String and Regexp works fine.

sasha:source brian$ ruby -v -e 'p Encoding.compatible? "abc", :abc'
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
-e:1: [BUG] Segmentation fault

Full report: https://gist.github.com/1651681

Thanks,
Brian

Associated revisions

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

  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

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

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

  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

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

  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

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

  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

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

  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

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

  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

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

  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

Revision 3c0ebab6
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) r34350:

    * encoding.c (rb_enc_compatible): fix segv on symbols.
      [ruby-core:42204] [Bug #5921]

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

History

Updated by brixen (Brian Shirai) over 7 years ago

It also SEGVs on trunk.

Updated by brixen (Brian Shirai) over 7 years ago

The following also causes a SEGV:

ruby -v -e 'sym = "\xff".force_encoding("binary").to_sym; p Encoding.compatible? sym, :abc'

Normally, two Symbols works. The trigger appears to be the symbol not being ASCII only. The following works:

ruby -v -e 'sym = "\x7f".force_encoding("binary").to_sym; p Encoding.compatible? sym, :abc'

Updated by brixen (Brian Shirai) over 7 years ago

And this also causes a SEGV:

ruby -v -e 're = Regexp.new("\xff".force_encoding("binary")); p Encoding.compatible? re, :abc'

Using "\x7f" works.

#4

Updated by naruse (Yui NARUSE) over 7 years ago

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

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


  • encoding.c (rb_enc_compatible): fix segv on symbols. [ruby-core:42204] [Bug #5921]

Also available in: Atom PDF