Project

General

Profile

Actions

Bug #3851

closed

Ruby 1.9.2p0 crash on filename with '['

Added by jlambert (Jon Lambert) over 14 years ago. Updated about 14 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-core:32478]

Description

=begin
On Windows Vista using ruby one-click installer.
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

If you have a left bracket in the file name, ruby crashes

Example:

ruby s[s

Windows event info:
Faulting application ruby.exe, version 1.9.2.0, time stamp 0x4c6d7c5e, faulting module msvcrt-ruby191.dll,
version 1.9.2.0, time stamp 0x4c6d7c5e, exception code 0xc0000005, fault offset 0x0004f601, process id 0xa08,
application start time 0x01cb5865dfb1d879.
=end

Actions #1

Updated by luislavena (Luis Lavena) over 14 years ago

=begin
Using quotes or not around the filename, it still crashes.

trunk does too.

1.8.7 does not:

type "s[s"
puts "hi"

ruby -v "s[s"
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
hi

=end

Actions #2

Updated by zenspider (Ryan Davis) over 14 years ago

=begin

On Sep 19, 2010, at 20:05 , Luis Lavena wrote:

Issue #3851 has been updated by Luis Lavena.

Using quotes or not around the filename, it still crashes.

trunk does too.

1.8.7 does not:

type "s[s"
puts "hi"

ruby -v "s[s"
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
hi

This doesn't reproduce on OSX. If I had to guess, prolly not on any unix/linux.

Passed: 1.9.2-p0, 1.9.1-p129, 1.8.6-p399, 1.8.7-p302

=end

Actions #3

Updated by luislavena (Luis Lavena) over 14 years ago

=begin
On Mon, Sep 20, 2010 at 12:43 AM, Ryan Davis wrote:

This doesn't reproduce on OSX. If I had to guess, prolly not on any unix/linux.

Passed: 1.9.2-p0, 1.9.1-p129, 1.8.6-p399, 1.8.7-p302

Nor on Linux, this seems strictly related to argument parsing on
Windows as this works:

ruby -I. -ve "load 's[s'"
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
hi

--
Luis Lavena
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

=end

Actions #4

Updated by phasis68 (Heesob Park) over 14 years ago

=begin
I think this must be a bug.

Here is a patch for the trunk:

--- dir.c 2010-09-20 14:12:13.000000000 +0900
+++ dir.c.new 2010-09-20 14:12:56.000000000 +0900
@@ -120,6 +120,7 @@
if (!*t1)
return NULL;
p = t1 + (r = rb_enc_mbclen(t1, pend, enc));

  •   if (!*p) return NULL;
      if (p[0] == '-' && p[1] != ']') {
          const char *t2 = p + 1;
          int r2;
    

=end

Actions #5

Updated by jlambert (Jon Lambert) over 14 years ago

=begin
I actually ran across the problem by mistyping.

rspec spec/ as rspec s[ec/

ruby [foo
crash

ruby fo[
ruby: No such file or directory -- fo[ (LoadError)

ruby fo[o
ruby: No such file or directory -- fo[o (LoadError)

ruby a[o
crash

ruby f[o
ruby: No such file or directory -- f[o (LoadError)

ruby foo[bar
ruby: No such file or directory -- foo[bar (LoadError)

Seems to happen if [ is in positions 1 or 2 and follows particular characters like s or a as above.
Encoding issue?

=end

Actions #6

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

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

=begin
This issue was solved with changeset r29306.
Jon, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0