Project

General

Profile

Actions

Bug #11610

closed

Segfault when assigning to ARGV

Added by josh.cheek (Josh Cheek) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin13]
[ruby-core:71140]

Description

This causes a segfault:

seq 3 | ruby -ne 'ARGV[$.]=$_'

These similar ones don't:

seq 3 | ruby -e 'ARGV[0] = "abc"'
seq 3 | ruby -ne 'BEGIN{a=[]}; a[$.]=$_'

Here is the output:

-e:1: [BUG] Segmentation fault at 0x00000000000008
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin13]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   for more details.

-- Control frame information -----------------------------------------------
c:0004 p:---- s:0009 e:000008 CFUNC  :gets
c:0003 p:---- s:0007 e:000006 CFUNC  :gets
c:0002 p:0025 s:0004 E:001370 EVAL   -e:1 [FINISH]
c:0001 p:0000 s:0002 E:001ff0 TOP    [FINISH]

-- Ruby level backtrace information ----------------------------------------
-e:1:in `<main>'
-e:1:in `gets'
-e:1:in `gets'

-- Machine register context ------------------------------------------------
 rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x0000000000000000
 rdx: 0x00007fcf40409840 rdi: 0x0000000000000008 rsi: 0x0000000000000000
 rbp: 0x00007fff5caabb50 rsp: 0x00007fff5caabb30  r8: 0x0000000000000008
  r9: 0x00000001031d6aa0 r10: 0x00007fcf404070d0 r11: 0xfffffffffffffff8
 r12: 0x00007fcf40409840 r13: 0x0000000000000008 r14: 0x0000000000000008
 r15: 0x0000000000000008 rip: 0x0000000103277a3e rfl: 0x0000000000010246

-- C level backtrace information -------------------------------------------
0   ruby                                0x00000001032ecdeb rb_vm_bugreport + 155
1   ruby                                0x0000000103191e80 rb_bug_context + 480
2   ruby                                0x00000001032696b3 sigsegv + 83
3   libsystem_platform.dylib            0x00007fff8ff285aa _sigtramp + 26
4   ruby                                0x0000000103277a3e rb_enc_str_coderange + 14
5   ???                                 0x0000000000000000 0x0 + 0

-- Other runtime information -----------------------------------------------

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 rational.so
    2 complex.so
    3 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/x86_64-darwin13/enc/encdb.bundle
    4 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/x86_64-darwin13/enc/trans/transdb.bundle
    5 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/unicode_normalize.rb
    6 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/x86_64-darwin13/rbconfig.rb
    7 thread.rb
    8 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/x86_64-darwin13/thread.bundle
    9 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/compatibility.rb
   10 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/defaults.rb
   11 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/deprecate.rb
   12 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/errors.rb
   13 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/version.rb
   14 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/requirement.rb
   15 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/platform.rb
   16 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/basic_specification.rb
   17 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/stub_specification.rb
   18 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/util/stringio.rb
   19 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/specification.rb
   20 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/exceptions.rb
   21 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb
   22 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb
   23 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
   24 /Users/josh/.rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Don't forget to include the above Crash Report log file.
For details: http://www.ruby-lang.org/bugreport.html

fish: Process 99401, 'ruby' from job 7, 'seq 3 | ruby -ne 'ARGV[$.]=$_'' terminated by signal SIGABRT (Abort)
Actions #1

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Closed

Applied in changeset r52211.


io.c: check ARGV element type

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 8 years ago

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

Backported into ruby_2_2 branch at r52650.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0