Project

General

Profile

Actions

Bug #17162

closed

Dir['**/*'] : stack smashing detected when listing big amount of directories

Added by kawsay (Clément Coquille) over 4 years ago. Updated almost 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]
[ruby-core:99967]

Description

When I try to recursively list directories, the instructions returns an error "*** stack smashing detected ***" / "[BUG] Illegal instruction".
Error only happens when I try to list a big amount of directories.

Specificity:

  • irb
  • WSL / Start Command Prompt With Ruby (logged as domain administrator)
  • remote drive mapped through "net use Z: \remote_storage"

Log:

2:\>irb
irb(main):001:0> Dir['**/*']                                                                                                                 *** stack smashing detected ***:  terminated
 (irb):1: [BUG] Illegal instruction
ruby 2.6.6p146 (2020-03-31 revision 67876) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:0022 p:---- s:0108 e:000107 CFUNC  :[]
c:0021 p:0011 s:0103 e:000102 EVAL   (irb):1 [FINISH]
c:0020 p:---- s:0100 e:000099 CFUNC  :eval
c:0019 p:0021 s:0092 e:000091 METHOD C:/Ruby26-x64/lib/ruby/2.6.0/irb/workspace.rb:85
c:0018 p:0056 s:0084 e:000082 METHOD C:/Ruby26-x64/lib/ruby/2.6.0/irb/context.rb:385
c:0017 p:0020 s:0075 e:000074 BLOCK  C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:493
c:0016 p:0025 s:0072 e:000071 METHOD C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:647
c:0015 p:0008 s:0066 e:000065 BLOCK  C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:490
c:0014 p:0100 s:0061 e:000060 BLOCK  C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:246 [FINISH]
c:0013 p:---- s:0057 e:000056 CFUNC  :loop
c:0012 p:0006 s:0053 e:000052 BLOCK  C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:232 [FINISH]
c:0011 p:---- s:0050 e:000049 CFUNC  :catch
c:0010 p:0012 s:0045 e:000044 METHOD C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:231
c:0009 p:0034 s:0041 E:0011f8 METHOD C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:489
c:0008 p:0005 s:0036 e:000035 BLOCK  C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:428 [FINISH]
c:0007 p:---- s:0033 e:000032 CFUNC  :catch
c:0006 p:0064 s:0028 E:001228 METHOD C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:427
c:0005 p:0102 s:0023 e:000022 METHOD C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:383
c:0004 p:0019 s:0017 e:000016 TOP    C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11 [FINISH]
c:0003 p:---- s:0014 e:000013 CFUNC  :load
c:0002 p:0120 s:0009 E:000a68 EVAL   C:/Ruby26-x64/bin/irb.cmd:31 [FINISH]
c:0001 p:0000 s:0003 E:001e70 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
C:/Ruby26-x64/bin/irb.cmd:31:in `<main>'
C:/Ruby26-x64/bin/irb.cmd:31:in `load'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:383:in `start'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:427:in `run'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:427:in `catch'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:428:in `block in run'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:489:in `eval_input'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:231:in `catch'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:232:in `loop'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:490:in `block in eval_input'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:647:in `signal_status'
C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb:493:in `block (2 levels) in eval_input'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/context.rb:385:in `evaluate'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/workspace.rb:85:in `evaluate'
C:/Ruby26-x64/lib/ruby/2.6.0/irb/workspace.rb:85:in `eval'
(irb):1:in `irb_binding'
(irb):1:in `[]'

-- C level backtrace information -------------------------------------------
C:\WINDOWS\SYSTEM32\ntdll.dll(NtWaitForSingleObject+0x14) [0x00007ffeeb23c0f4]
C:\WINDOWS\System32\KERNELBASE.dll(WaitForSingleObjectEx+0x93) [0x00007ffee8768a83]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_vm_bugreport+0x30b) [0x000000006a68ff2b]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_bug_context+0x81) [0x000000006a4d1dc1]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_check_safe_obj+0xc3) [0x000000006a5eeb83]
 [0x00000000004023a5]
C:\WINDOWS\System32\msvcrt.dll(_C_specific_handler+0x98) [0x00007ffeea868048]
C:\WINDOWS\SYSTEM32\ntdll.dll(_chkstk+0x11f) [0x00007ffeeb2411cf]
C:\WINDOWS\SYSTEM32\ntdll.dll(RtlRaiseException+0x399) [0x00007ffeeb20a209]
C:\WINDOWS\SYSTEM32\ntdll.dll(KiUserExceptionDispatcher+0x2e) [0x00007ffeeb23fe3e]
C:\Ruby26-x64\bin\ruby_builtin_dlls\libssp-0.dll(_vsprintf_chk+0x1840) [0x0000000068ac3270]
C:\Ruby26-x64\bin\ruby_builtin_dlls\libssp-0.dll(_stack_chk_fail+0x15) [0x0000000068ac14c5]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(tgamma+0x2622) [0x000000006a69c5d2]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_w32_uspawn+0xba) [0x000000006a6a7bda]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_w32_uopendir+0x72) [0x000000006a6a8002]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_debug_counter_show_results+0x2475) [0x000000006a4a9c85]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_thread_call_without_gvl+0x6b) [0x000000006a639cdb]
C:\Ruby26-x64\bin\x64-msvcrt-ruby260.dll(rb_debug_counter_show_results+0x59e5) [0x000000006a4ad1f5]

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

* Loaded script: irb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/enc/encdb.so
    5 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/enc/trans/transdb.so
    6 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/enc/windows_1252.so
    7 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/rbconfig.rb
    8 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/compatibility.rb
    9 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/defaults.rb
   10 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/deprecate.rb
   11 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/errors.rb
   12 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/version.rb
   13 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/requirement.rb
   14 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/platform.rb
   15 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/basic_specification.rb
   16 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/stub_specification.rb
   17 C:/Ruby26-x64/lib/ruby/2.6.0/delegate.rb
   18 C:/Ruby26-x64/lib/ruby/2.6.0/uri/rfc2396_parser.rb
   19 C:/Ruby26-x64/lib/ruby/2.6.0/uri/rfc3986_parser.rb
   20 C:/Ruby26-x64/lib/ruby/2.6.0/uri/common.rb
   21 C:/Ruby26-x64/lib/ruby/2.6.0/uri/generic.rb
   22 C:/Ruby26-x64/lib/ruby/2.6.0/uri/file.rb
   23 C:/Ruby26-x64/lib/ruby/2.6.0/uri/ftp.rb
   24 C:/Ruby26-x64/lib/ruby/2.6.0/uri/http.rb
   25 C:/Ruby26-x64/lib/ruby/2.6.0/uri/https.rb
   26 C:/Ruby26-x64/lib/ruby/2.6.0/uri/ldap.rb
   27 C:/Ruby26-x64/lib/ruby/2.6.0/uri/ldaps.rb
   28 C:/Ruby26-x64/lib/ruby/2.6.0/uri/mailto.rb
   29 C:/Ruby26-x64/lib/ruby/2.6.0/uri.rb
   30 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/specification_policy.rb
   31 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/util/list.rb
   32 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/stringio.so
   33 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/specification.rb
   34 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/exceptions.rb
   35 C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0/ruby_installer/runtime/singleton.rb
   36 C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0/ruby_installer/runtime.rb
   37 C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0/ruby_installer/runtime/msys2_installation.rb
   38 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/fiddle.so
   39 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle/function.rb
   40 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle/closure.rb
   41 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle.rb
   42 C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0/ruby_installer/runtime/dll_directory.rb
   43 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle/value.rb
   44 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle/pack.rb
   45 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle/struct.rb
   46 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle/cparser.rb
   47 C:/Ruby26-x64/lib/ruby/2.6.0/fiddle/import.rb
   48 C:/Ruby26-x64/lib/ruby/2.6.0/win32/importer.rb
   49 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/enc/utf_16le.so
   50 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/enc/trans/utf_16_32.so
   51 C:/Ruby26-x64/lib/ruby/2.6.0/win32/registry.rb
   52 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/enc/trans/single_byte.so
   53 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/defaults/operating_system.rb
   54 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/util.rb
   55 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/bundler_version_finder.rb
   56 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/dependency.rb
   57 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_gem.rb
   58 C:/Ruby26-x64/lib/ruby/2.6.0/monitor.rb
   59 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb
   60 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_warn.rb
   61 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems.rb
   62 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/path_support.rb
   63 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/version.rb
   64 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/core_ext/name_error.rb
   65 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/levenshtein.rb
   66 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/jaro_winkler.rb
   67 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checker.rb
   68 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   69 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   70 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb
   71 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/method_name_checker.rb
   72 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/key_error_checker.rb
   73 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/null_checker.rb
   74 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean/formatters/plain_formatter.rb
   75 C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib/did_you_mean.rb
   76 C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb
   77 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/request_set/gem_dependency_api.rb
   78 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/request_set/lockfile/parser.rb
   79 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/request_set/lockfile/tokenizer.rb
   80 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/request_set/lockfile.rb
   81 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/request_set.rb
   82 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
   83 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/errors.rb
   84 C:/Ruby26-x64/lib/ruby/2.6.0/set.rb
   85 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb
   86 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
   87 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
   88 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
   89 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
   90 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb
   91 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb
   92 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb
   93 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb
   94 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
   95 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/state.rb
   96 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
   97 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb
   98 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb
   99 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
  100 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
  101 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
  102 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo/lib/molinillo.rb
  103 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/molinillo.rb
  104 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/activation_request.rb
  105 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/conflict.rb
  106 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/dependency_request.rb
  107 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/requirement_list.rb
  108 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/stats.rb
  109 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/set.rb
  110 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/api_set.rb
  111 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/composed_set.rb
  112 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/best_set.rb
  113 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/current_set.rb
  114 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/git_set.rb
  115 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/index_set.rb
  116 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/installer_set.rb
  117 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/lock_set.rb
  118 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/vendor_set.rb
  119 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/source_set.rb
  120 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/specification.rb
  121 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/spec_specification.rb
  122 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/api_specification.rb
  123 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/git_specification.rb
  124 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/index_specification.rb
  125 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/installed_specification.rb
  126 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/local_specification.rb
  127 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/lock_specification.rb
  128 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver/vendor_specification.rb
  129 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/resolver.rb
  130 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/source/git.rb
  131 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/source/installed.rb
  132 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/source/specific_file.rb
  133 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/source/local.rb
  134 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/source/lock.rb
  135 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/source/vendor.rb
  136 C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/source.rb
  137 C:/Ruby26-x64/lib/ruby/2.6.0/e2mmap.rb
  138 C:/Ruby26-x64/lib/ruby/2.6.0/irb/init.rb
  139 C:/Ruby26-x64/lib/ruby/2.6.0/irb/workspace.rb
  140 C:/Ruby26-x64/lib/ruby/2.6.0/irb/inspector.rb
  141 C:/Ruby26-x64/lib/ruby/2.6.0/irb/src_encoding.rb
  142 C:/Ruby26-x64/lib/ruby/2.6.0/irb/magic-file.rb
  143 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/io/console.so
  144 C:/Ruby26-x64/lib/ruby/2.6.0/timeout.rb
  145 C:/Ruby26-x64/lib/ruby/2.6.0/forwardable/impl.rb
  146 C:/Ruby26-x64/lib/ruby/2.6.0/forwardable.rb
  147 C:/Ruby26-x64/lib/ruby/site_ruby/reline/version.rb
  148 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/pathname.so
  149 C:/Ruby26-x64/lib/ruby/2.6.0/pathname.rb
  150 C:/Ruby26-x64/lib/ruby/site_ruby/reline/config.rb
  151 C:/Ruby26-x64/lib/ruby/site_ruby/reline/key_actor/base.rb
  152 C:/Ruby26-x64/lib/ruby/site_ruby/reline/key_actor/emacs.rb
  153 C:/Ruby26-x64/lib/ruby/site_ruby/reline/key_actor/vi_command.rb
  154 C:/Ruby26-x64/lib/ruby/site_ruby/reline/key_actor/vi_insert.rb
  155 C:/Ruby26-x64/lib/ruby/site_ruby/reline/key_actor.rb
  156 C:/Ruby26-x64/lib/ruby/site_ruby/reline/key_stroke.rb
  157 C:/Ruby26-x64/lib/ruby/site_ruby/reline/kill_ring.rb
  158 C:/Ruby26-x64/lib/ruby/site_ruby/reline/unicode/east_asian_width.rb
  159 C:/Ruby26-x64/lib/ruby/site_ruby/reline/unicode.rb
  160 C:/Ruby26-x64/lib/ruby/2.6.0/fileutils/version.rb
  161 C:/Ruby26-x64/lib/ruby/2.6.0/x64-mingw32/etc.so
  162 C:/Ruby26-x64/lib/ruby/2.6.0/fileutils.rb
  163 C:/Ruby26-x64/lib/ruby/2.6.0/tmpdir.rb
  164 C:/Ruby26-x64/lib/ruby/2.6.0/tempfile.rb
  165 C:/Ruby26-x64/lib/ruby/site_ruby/reline/line_editor.rb
  166 C:/Ruby26-x64/lib/ruby/site_ruby/reline/history.rb
  167 C:/Ruby26-x64/lib/ruby/site_ruby/reline/windows.rb
  168 C:/Ruby26-x64/lib/ruby/site_ruby/reline/general_io.rb
  169 C:/Ruby26-x64/lib/ruby/site_ruby/reline.rb
  170 C:/Ruby26-x64/lib/ruby/site_ruby/readline.rb
  171 C:/Ruby26-x64/lib/ruby/2.6.0/irb/input-method.rb
  172 C:/Ruby26-x64/lib/ruby/2.6.0/irb/output-method.rb
  173 C:/Ruby26-x64/lib/ruby/2.6.0/irb/context.rb
  174 C:/Ruby26-x64/lib/ruby/2.6.0/irb/extend-command.rb
  175 C:/Ruby26-x64/lib/ruby/2.6.0/irb/notifier.rb
  176 C:/Ruby26-x64/lib/ruby/2.6.0/irb/slex.rb
  177 C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-token.rb
  178 C:/Ruby26-x64/lib/ruby/2.6.0/irb/ruby-lex.rb
  179 C:/Ruby26-x64/lib/ruby/2.6.0/irb/locale.rb
  180 C:/Ruby26-x64/lib/ruby/2.6.0/irb/version.rb
  181 C:/Ruby26-x64/lib/ruby/2.6.0/irb.rb
  182 C:/Ruby26-x64/lib/ruby/site_ruby/2.6.0/irbrc_predefiner.rb
  183 C:/Ruby26-x64/lib/ruby/2.6.0/irb/ext/save-history.rb
  184 C:/Ruby26-x64/lib/ruby/2.6.0/irb/completion.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: https://www.ruby-lang.org/bugreport.html

As a non-native English, excuse my imprecision; and as a Ruby beginner, excuse me if this report isn't relevant.

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

One possible approach to avoiding the stack smash is to limit the recursion allowed during directory globbing. Here's a simple approach that does that: https://github.com/jeremyevans/ruby/commit/29edc847b991bb59185b15c16988bc8004299c16

Unfortunately, this simple approach has some disadvantages:

  • May artificially limit recursion (32 levels may not be enough)
  • Doesn't allow a user to specify a recursion level via a keyword argument
  • May leak memory in failure case

If other committers are in favor of this approach despite the limitations, I can submit a pull request for it.

Updated by kawsay (Clément Coquille) over 4 years ago

Here's a repository with 2 scripts that might help debugging.

  • one to create a lot of directories & sub-directories
  • another to clear newly created directories

https://gitlab.com/kawsay/ruby-bug-17162

Sadly I haven't got a lot of time to consecrate to this, nevertheless I'll keep you updated if I manage to recreate the bug on a test environment

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

Although I couldn't reproduce this issue even with 68 levels (exceeded the NTFS limit at that time), does this help?

diff --git a/dir.c b/dir.c
index 49e6818d25c..399913e82d0 100644
--- a/dir.c
+++ b/dir.c
@@ -2271,6 +2271,8 @@ glob_helper(
     int escape = !(flags & FNM_NOESCAPE);
     size_t pathlen = baselen + namelen;
 
+    CHECK_STACK_OVERFLOW();
+
     for (cur = beg; cur < end; ++cur) {
 	struct glob_pattern *p = *cur;
 	if (p->type == RECURSIVE) {

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

Mistaken.

diff --git a/dir.c b/dir.c
index 49e6818d25c..50749b8d01c 100644
--- a/dir.c
+++ b/dir.c
@@ -2251,2 +2251,4 @@ glob_getent(ruby_glob_entries_t *ent, int flags, rb_encoding *enc)
 
+void rb_check_stack_overflow(void);
+
 static int
@@ -2273,2 +2275,4 @@ glob_helper(
 
+    rb_check_stack_overflow();
+
     for (cur = beg; cur < end; ++cur) {
diff --git a/vm_eval.c b/vm_eval.c
index b26c88ffe0c..90ae9c6af29 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -306,2 +306,8 @@ stack_check(rb_execution_context_t *ec)
 
+void
+rb_check_stack_overflow(void)
+{
+    stack_check(GET_EC());
+}
+
 static inline const rb_callable_method_entry_t *rb_search_method_entry(VALUE recv, ID mid);
Actions #5

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

  • Status changed from Open to Closed

Applied in changeset git|083c5f08ec4e95c9b75810d46f933928327a5ab3.


Check stack overflow in recursive glob_helper [Bug #17162]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0