fix autotest SystemStackError with very large numbers of files 

fix autotest failure with very large numbers of files (e.g. git repo with lots of objects). 
see https://bugs.ruby-lang.org/issues/4040 for the origin of this bug (which is really an unfixed ruby bug)