Project

General

Profile

Bug #16382

SystemStackError thrown when running `LC_ALL="C" RUBYLIB=".:" ruby -E cp932:utf-8 aaa.rb` from where the current dir contains Japanese characters

Added by yuki24 (Yuki Nishijima) 11 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0dev (2019-11-29T23:00:40Z master 0b1b2f2442) [x86_64-darwin18]
[ruby-core:96029]

Description

Steps to reproduce

~/GitHub/ruby/did_you_mean/テスト$ LC_ALL="C" RUBYLIB=".:" ruby -E cp932:utf-8 aaa.rb
Traceback (most recent call last):
    2: from <internal:gem_prelude>:5:in `<internal:gem_prelude>'
    1: from /Users/yuki/.rbenv/versions/2.7.0-dev/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
/Users/yuki/.rbenv/versions/2.7.0-dev/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require': stack level too deep (SystemStackError)

The key points are:

  • The current directory contains one or more Japanese character (perhaps non-alphabet char is what's causing the issue, but I'm unfamiliar with other types of chars)
  • Only happens when LC_ALL="C" RUBYLIB=".:" environment variables and the option -E cp932:utf-8 are given
  • The existing of the file that is supposed to be run by the executable does not seem to matter

Actual

A SystemStackError is thrown.

Expected

The file specified should be run or Ruby should throw a No such file or directory -- aaa.rb (LoadError) error.

Updated by yuki24 (Yuki Nishijima) 11 months ago

  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN to 2.5: REQUIRED, 2.6: DONTNEED

2.6.5 seems to be working fine:

~/GitHub/ruby/did_you_mean/テスト$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
~/GitHub/ruby/did_you_mean/テスト$ echo "puts 'ok'" > a.rb
~/GitHub/ruby/did_you_mean/テスト$ LC_ALL="C" RUBYLIB=".:" ruby -E cp932:utf-8 a.rb
ok

while 2.5.5 seems to have the same issue:

~/GitHub/ruby/did_you_mean/テスト$ ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
~/GitHub/ruby/did_you_mean/テスト$ LC_ALL="C" RUBYLIB=".:" ruby -E cp932:utf-8 a.rb
Traceback (most recent call last):
    2: from <internal:gem_prelude>:5:in `<internal:gem_prelude>'
    1: from /Users/yuki/.rbenv/versions/2.5.5/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/yuki/.rbenv/versions/2.5.5/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': stack level too deep (SystemStackError)

And Interestingly enough, 2.5.6 and 2.5.7 seem to be running into a different issue:

~/GitHub/ruby/did_you_mean/テスト$ ruby -v
ruby 2.5.6p201 (2019-08-28 revision 67796) [x86_64-darwin18]
~/GitHub/ruby/did_you_mean/テスト$ LC_ALL="C" RUBYLIB=".:" ruby -E cp932:utf-8 a.rb
Illegal instruction: 4

~/GitHub/ruby/did_you_mean/テスト$ ruby -v
ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-darwin18]
~/GitHub/ruby/did_you_mean/テスト$ LC_ALL="C" RUBYLIB=".:" ruby -E cp932:utf-8 a.rb
Illegal instruction: 4
#2

Updated by nobu (Nobuyoshi Nakada) 11 months ago

  • Status changed from Open to Closed

Applied in changeset git|14a17063a11a01d518b4bbaf0eb967330aec3984.


Fixed stack overflow [Bug #16382]

Get rid of infinite recursion in expanding a load path to the real
path while loading a transcoder.

Updated by Tietew (Toru Iwase) 11 months ago

same issue with 2.6.5 [x86_64-linux].
I think backport 2.6 is REQUIRED.

~/tmp/テスト$ echo "puts 'ok'" > aaa.rb
~/tmp/テスト$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
~/tmp/テスト$ LC_ALL="C" RUBYLIB=".:" ruby -E cp932:utf-8 aaa.rb
Traceback (most recent call last):
        2: from <internal:gem_prelude>:5:in `<internal:gem_prelude>'
        1: from /usr/local/anyenv/envs/rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/anyenv/envs/rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': stack level too deep (SystemStackError)

No need to set LC_ALL and encoding:

~/tmp/テスト$ echo $LANG
ja_JP.UTF-8
~/tmp/テスト$ ruby aaa.rb
ok
~/tmp/テスト$ RUBYLIB="." ruby aaa.rb
Traceback (most recent call last):
        2: from <internal:gem_prelude>:5:in `<internal:gem_prelude>'
        1: from /usr/local/anyenv/envs/rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/anyenv/envs/rbenv/versions/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': stack level too deep (SystemStackError)

Also available in: Atom PDF