Project

General

Profile

Backport #1594

Dir.foreach() mistakenly throws EINVAL in Windows

Added by bdezonia (Barry DeZonia) over 10 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
[ruby-core:23769]

Description

=begin
On Windows 2003 Server (64 bit) I use the attached script to trim files off a disk backup. This code runs fine for days and days but infrequently crashes on the same line of the script: (line 137 - Dir.foreach(copyFullDirName) do | dirEntry |).

The backtrace is:
D:/BackupScripts/trimMachines.rb:137:in open': Invalid argument - x:\.\document
s and settings\pdculbert\Desktop\Pedram stats\Raw BBS Data by State\FCV30ALL_TES
T\ComDyn (Errno::EINVAL)
from D:/BackupScripts/trimMachines.rb:137:in
foreach'
from D:/BackupScripts/trimMachines.rb:137:in trimDirectory'
from D:/BackupScripts/trimMachines.rb:142:in
trimDirectory'
from D:/BackupScripts/trimMachines.rb:137:in foreach'
from D:/BackupScripts/trimMachines.rb:137:in
trimDirectory'
from D:/BackupScripts/trimMachines.rb:142:in trimDirectory'
from D:/BackupScripts/trimMachines.rb:137:in
foreach'
from D:/BackupScripts/trimMachines.rb:137:in trimDirectory'
... 19 levels...
from D:/BackupScripts/trimMachines.rb:200:in
trimMachines'
from D:/BackupScripts/trimMachines.rb:187:in foreach'
from D:/BackupScripts/trimMachines.rb:187:in
trimMachines'
from D:/BackupScripts/trimMachines.rb:253

When I check out if the path specified is invalid it in fact exists, its file permissions are correct, etc. The biggest issue (I think) is that the directory contains 121,954 files. Note that the script loops over this directory a number of times successfully before it crashes on one pass some days (or weeks) later.

I've tested that the "x:.\" notation is fine. The directory recursion level is only 8 levels and I don't get a stack too deep error.

Along the "x:.\documents and settings\pdculbert\Desktop\Pedram stats\Raw BBS Data by State\FCV30ALL_TEST\ComDyn" path on the hard drive:

. contains 4 entries
documents and settings contains 17 entries
pdculbert contains 221 entries
Desktop contains 69 entries
Pedram stats contains 16 entries
Raw BBS Data by State contains 82 entries
FCV30ALL_TEST contains 5 entries
ComDyn contains 121,956 entries
=end


Files

backup.rb (8.61 KB) backup.rb bdezonia (Barry DeZonia), 06/10/2009 12:55 AM
trimMachines.rb (7.25 KB) trimMachines.rb bdezonia (Barry DeZonia), 06/10/2009 02:24 AM

History

#1

Updated by bdezonia (Barry DeZonia) over 10 years ago

=begin
I attached the wrong file. Please refer to this newly attached file trimMachines.rb
=end

#2

Updated by rogerdpack (Roger Pack) over 10 years ago

=begin
do you have a way to recreate this easily?

You might want to try to step through with gdb and see what is going on :)
You might be able to set gdb to break on just the right line.

http://betterlogic.com/roger/?p=1440

My guess is that it's a windows OS "resource unavailable" or something that happens every so often when you hit it too hard. Trying with other versions of windows might help.

In the meantime you could add a begin/rescue around it to retry and see if that helps.

Cheers!
-=r
=end

#3

Updated by akr (Akira Tanaka) over 8 years ago

  • Project changed from Ruby to Ruby master

Updated by naruse (Yui NARUSE) over 8 years ago

  • Status changed from Open to Assigned
  • Assignee set to arton (Akio Tajima)

Updated by nahi (Hiroshi Nakamura) over 8 years ago

  • Target version set to 1.9.3
#6

Updated by usa (Usaku NAKAMURA) over 8 years ago

  • Project changed from Ruby master to Ruby 1.8
  • Target version deleted (1.9.3)

I can't reproduce at least with ruby 1.9, and the reporter says his ruby is 1.8.6.

#7

Updated by jeremyevans0 (Jeremy Evans) 4 months ago

  • ruby -v deleted (ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32])
  • Status changed from Assigned to Closed
  • Project changed from Ruby 1.8 to Backport187
  • Tracker changed from Bug to Backport

Also available in: Atom PDF