Skip Menu |

This queue is for tickets about the Win32-UTCFileTime CPAN distribution.

Report information
The Basics
Id: 37535
Status: resolved
Priority: 0/
Queue: Win32-UTCFileTime

People
Owner: Nobody in particular
Requestors: bitcard [...] post2.25u.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.48
Fixed in: (no value)



Hello, Win32::UTCFileTime::stat() returns a wrong zero atime/ctime/mtime value in some situations. I encountered the problem when checking timestamps in a custom Perl script for a file mirror. Only very few files are affected, and it seems that the output is only wrong in those cases where normal stat() suffers from the known DST problem. The files in question are located on a network drive. Behaviour is as follows: 1/ normal (C-runtime) stat() returns valid atime/ctime/mtime values 2/ Win32::UTCFileTime::stat() returns zero times for the same file 3/ normal (C-runtime) stat() returns zero atime/ctime/mtime values also when Win32::UTCFileTime is *only* loaded ("use Win32::UTCFileTime;" at start of Perl script) and normal stat() is used afterwards. So there seems to be a side-effect on normal stat() in this case. I also tried to use Win32::UTCFileTime::alt_stat(). In that case, I get an error $ErrStr that says "Can't open file ... for reading: The process cannot access the file because it is being used by another process at checkstat.pl line 21". The following table summarzies the output of 1/2/3/ above: normal stat(): UTC-stat(): normal stat() w/ UTC-package loaded info stat() stat() stat() dev: 2 2 2 ino: 0 0 0 mode: 33206 33206 33206 nlink: 1 1 1 uid: 0 0 0 gid: 0 0 0 rdev: 2 2 2 size: 56832 56832 56832 atime: 1215510518 0 0 mtime: 1215510518 0 0 ctime: 1197889620 0 0 blksize: 0 0 0 blocks: 0 0 0 In the attached zip file, you will find "checkstat.pl" that I used for checking this problem. I am using o Win32-UTCFileTime-1.48 o (ActiveState) perl5.10.0 (see zip file perl-v.txt for full information). Any help highly appreciated. If this is of any help, I can perform further runs for debugging purposes of course.
Subject: stat.zip
Download stat.zip
application/x-zip 2.1k

Message body not shown because it is not plain text.

Subject: subject omitted
From: bitcard [...] post2.25u.com
Sorry - forgot to add subject to this bug. It should read zero atime/ctime/mtime for some files located on network drives Thanks, /alex
Subject: RE: [rt.cpan.org #37535]
Date: Wed, 9 Jul 2008 09:57:16 +0100
To: <bug-Win32-UTCFileTime [...] rt.cpan.org>
From: "Steve Hay" <SteveHay [...] planit.com>
Alexander Ost via RT wrote: Show quoted text
> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=37535 > > > Hello, > > Win32::UTCFileTime::stat() returns a wrong zero atime/ctime/mtime > value in some situations. > > I encountered the problem when checking timestamps in a custom Perl > script for a file mirror. Only very few files are affected, and it > seems that the output is only wrong in those cases where normal > stat() suffers from the known DST problem. > > The files in question are located on a network drive. > > Behaviour is as follows: > > 1/ normal (C-runtime) stat() returns valid atime/ctime/mtime values > > 2/ Win32::UTCFileTime::stat() returns zero times for the same file > > 3/ normal (C-runtime) stat() returns zero atime/ctime/mtime values > also when Win32::UTCFileTime is *only* loaded ("use > Win32::UTCFileTime;" at start of Perl script) and normal stat() is > used afterwards. So there seems to be a side-effect on normal stat() > in this case.
The above isn't quite correct, and neither is your example script. Note that a plain "use Win32::UTCFileTime;" *does* still override stat() in the current package, so case 3 above is identical to case 2, hence you get the same result. The stat() override is exported by default, so you have to *explicitly* request no imports with an empty import list in order to load Win32::UTCFileTime without overriding stat(): "use Win32::UTCFileTime ();". Doing this gives the same result as case 1, i.e. there is no side-effect of loading the module. Show quoted text
> > I also tried to use Win32::UTCFileTime::alt_stat(). In that case, I > get an error $ErrStr that says > "Can't open file ... for reading: The process cannot access the file > because it is being used by another process at checkstat.pl line 21".
That's highly significant, and has allowed me to reproduce the problem. It seems that the DST season has nothing to do with it, and nor does the file being on a network drive. The problem is that if the file is open by some other process that is denying access for reading then CORE::stat() still works, Win32::UTCFileTime::stat() returns success but has 0 in the *time fields, and Win32::UTCFileTime::alt_stat() gives the error that you've quoted. The attached program simulates this scenario using another CPAN module of mine, Win32::SharedFileOpen. Typical output is: info stat() dev: 2 ino: 0 mode: 33206 nlink: 1 uid: 0 gid: 0 rdev: 2 size: 2623 atime: 1215589709 mtime: 1215538338 ctime: 1215538338 blksize: 0 blocks: 0 info UTC-stat() dev: 2 ino: 0 mode: 33206 nlink: 1 uid: 0 gid: 0 rdev: 2 size: 2623 atime: 0 mtime: 0 ctime: 0 blksize: 0 blocks: 0 Win32::UTCFileTime::alt_stat() failed: Can't open file 'perl-v.txt' for reading: The process cannot access the file because it is being used by another process at checkstat2.pl line 45. In your case, I would guess that you're getting intermittent failures due to other processes occasionally having the file that you are trying to stat() open already and denying access for other readers. This is presumably quite likely to happen if you have anti-virus software running, for example. I have located where it is going wrong in the Win32::UTCFileTime source code and hope to upload a fixed version to CPAN soon. I'll reply here when I have a fix. Thanks for the report! Cheers, Steve
Download stat2.zip
application/x-zip-compressed 531b

Message body not shown because it is not plain text.

From: bitcard [...] post2.25u.com
Hi, I see. Thanks for your quick analysis - and also for all your work on this very useful package in general! BR/alex
Subject: RE: [rt.cpan.org #37535]
Date: Thu, 10 Jul 2008 08:30:46 +0100
To: <bug-Win32-UTCFileTime [...] rt.cpan.org>
From: "Steve Hay" <SteveHay [...] planit.com>
Alexander Ost via RT wrote: Show quoted text
> Queue: Win32-UTCFileTime > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=37535 > > > Hi, > > I see. Thanks for your quick analysis - and also for all your work on > this very useful package in general!
Should now be fixed in 1.49, which I've just uploaded to CPAN. Please give it a try and let me know if it solves your problem. Cheers, Steve
No reply, so I'm assuming this is fixed.