Skip to content

Failed test 'mtime preserved by copy() while testing cross-partition' #20018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
g055s00 opened this issue Jul 30, 2022 · 8 comments · Fixed by #20064
Closed

Failed test 'mtime preserved by copy() while testing cross-partition' #20018

g055s00 opened this issue Jul 30, 2022 · 8 comments · Fixed by #20064

Comments

@g055s00
Copy link

g055s00 commented Jul 30, 2022

Tried different MSVC and Perl versions.

ok 52 - contents preserved
not ok 53 - mtime preserved by copy() while testing cross-partition

#   Failed test 'mtime preserved by copy() while testing cross-partition'
#   at ../lib/File/Copy.t line 126.
#          got: '1000007200'
#     expected: '1000003600'

Test Summary Report
-------------------
../lib/File/Copy.t (Wstat: 256 (exited 1) Tests: 466 Failed: 1)
  Failed test:  53
  Non-zero exit status: 1
Files=1, Tests=466,  0 wallclock secs ( 0.00 usr +  0.06 sys =  0.06 CPU)
Result: FAIL
NMAKE : fatal error U1077: '.\perl.exe' : return code '0x1'
Stop.

Steps to Reproduce
Build using win32/Makefile in accordance with the README.win32

Perl configuration

Summary of my perl5 (revision 5 version 36 subversion 0) configuration:
  
  Platform:
    osname=MSWin32
    osvers=10.0.19044.1865
    archname=MSWin32-x64-multi-thread
    uname=''
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cl'
    ccflags ='-nologo -GF -W3 -MD -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS  -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS'
    optimize='-O1 -Zi -GL -fp:precise'
    cppflags='-DWIN32'
    ccversion='19.32.31332'
    gccversion=''
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=undef
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    ivtype='__int64'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='__int64'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='link'
    ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg  -libpath:"c:\perl\lib\CORE"  -machine:AMD64 -subsystem:console,"5.02"'
    libpth="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\\lib\x64"
    libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib vcruntime.lib ucrt.lib
    perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib vcruntime.lib ucrt.lib
    libc=ucrt.lib
    so=dll
    useshrplib=true
    libperl=perl536.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -ltcg  -libpath:"c:\perl\lib\CORE"  -machine:AMD64 -subsystem:console,"5.02"'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_TIMES
    HAVE_INTERP_INTERN
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_THREAD_SAFE_LOCALE
  Built under MSWin32
@jkeenan
Copy link
Contributor

jkeenan commented Jul 30, 2022

@mikhail-rakhmanov, for my own analysis I stripped down lib/File/Copy.t to the following program, which ran without incident on both Linux and FreeBSD.

$ cat gh-20018-mtime.pl 
use strict;
use warnings;
use File::Copy qw(move);
use Test::More;
{
  # Simulate a cross-partition copy/move by forcing rename to
  # fail.
  no warnings 'redefine';
  no warnings 'once';
  *CORE::GLOBAL::rename = sub { 0 };
}
# First we create a file
open(F, ">", "before-$$") or die $!;
binmode F; # for DOSISH platforms, because test 3 copies to stdout
printf F "ok\n";
close F;

note "before atime: " . (stat("before-$$"))[8];
note "before mtime: " . (stat("before-$$"))[9];

# Doesn't really matter what time it is as long as its not now.
my $time = 1000000000.12345;
utime( $time, $time, "before-$$" );
note "utime applied";
note "before atime: " . (stat("before-$$"))[8];
note "before mtime: " . (stat("before-$$"))[9];

# Recheck the mtime rather than rely on utime in case we're on a
# system where utime doesn't work or there's no mtime at all.
# The destination file will reflect the same difficulties.
my $mtime = (stat("before-$$"))[9];

ok move("before-$$", "after-$$"), 'move';
ok -e "after-$$",   'destination exists';
ok !-e "before-$$", 'source does not';

my $dest_mtime = (stat("after-$$"))[9];
is $dest_mtime, $mtime,
  "mtime $mtime preserved by copy() while testing cross-partition";

unlink "after-$$";
done_testing();

Could you try it on your Windows system(s) and tell us if you got the same failures?

We'll need to have this examined by people with more Windows experience than me.

@xenu, @sisyphus, @tonycoz, @craigberry

@g055s00
Copy link
Author

g055s00 commented Jul 30, 2022

@mikhail-rakhmanov, for my own analysis I stripped down lib/File/Copy.t to the following program, which ran without incident on both Linux and FreeBSD.

$ cat gh-20018-mtime.pl 
use strict;
use warnings;
use File::Copy qw(move);
use Test::More;
{
  # Simulate a cross-partition copy/move by forcing rename to
  # fail.
  no warnings 'redefine';
  no warnings 'once';
  *CORE::GLOBAL::rename = sub { 0 };
}
# First we create a file
open(F, ">", "before-$$") or die $!;
binmode F; # for DOSISH platforms, because test 3 copies to stdout
printf F "ok\n";
close F;

note "before atime: " . (stat("before-$$"))[8];
note "before mtime: " . (stat("before-$$"))[9];

# Doesn't really matter what time it is as long as its not now.
my $time = 1000000000.12345;
utime( $time, $time, "before-$$" );
note "utime applied";
note "before atime: " . (stat("before-$$"))[8];
note "before mtime: " . (stat("before-$$"))[9];

# Recheck the mtime rather than rely on utime in case we're on a
# system where utime doesn't work or there's no mtime at all.
# The destination file will reflect the same difficulties.
my $mtime = (stat("before-$$"))[9];

ok move("before-$$", "after-$$"), 'move';
ok -e "after-$$",   'destination exists';
ok !-e "before-$$", 'source does not';

my $dest_mtime = (stat("after-$$"))[9];
is $dest_mtime, $mtime,
  "mtime $mtime preserved by copy() while testing cross-partition";

unlink "after-$$";
done_testing();

Could you try it on your Windows system(s) and tell us if you got the same failures?

We'll need to have this examined by people with more Windows experience than me.

@xenu, @sisyphus, @tonycoz, @craigberry

# before atime: 1659209248
# before mtime: 1659209248
# utime applied
# before atime: 1000003600
# before mtime: 1000003600
ok 1 - move
ok 2 - destination exists
ok 3 - source does not
ok 4 - mtime 1000003600 preserved by copy() while testing cross-partition
1..4

@jkeenan
Copy link
Contributor

jkeenan commented Jul 30, 2022

$ cat gh-20018-mtime.pl 

...

my $time = 1000000000.12345;
utime( $time, $time, "before-$$" );
note "utime applied";
note "before atime: " . (stat("before-$$"))[8];
note "before mtime: " . (stat("before-$$"))[9];

# before atime: 1659209248
# before mtime: 1659209248
# utime applied
# before atime: 1000003600
# before mtime: 1000003600
ok 1 - move
ok 2 - destination exists
ok 3 - source does not
ok 4 - mtime 1000003600 preserved by copy() while testing cross-partition
1..4

Do you have any insight into why, on your system, applying utime() to modify the access and modification times of the test file caused those times to be recorded as 3600 seconds -- one hour -- greater than the time arbitrarily provided?

@Leont
Copy link
Contributor

Leont commented Jul 30, 2022

Do you have any insight into why, on your system, applying utime() to modify the access and modification times of the test file caused those times to be recorded as 3600 seconds -- one hour -- greater than the time arbitrarily provided?

@mikhail-rakhmanov what timezone are you in?

@g055s00
Copy link
Author

g055s00 commented Jul 30, 2022

Do you have any insight into why, on your system, applying utime() to modify the access and modification times of the test file caused those times to be recorded as 3600 seconds -- one hour -- greater than the time arbitrarily provided?

@mikhail-rakhmanov what timezone are you in?

UTC+03 Moscow was the issue
I changed it, and now test successful.

@jkeenan
Copy link
Contributor

jkeenan commented Jul 30, 2022

Do you have any insight into why, on your system, applying utime() to modify the access and modification times of the test file caused those times to be recorded as 3600 seconds -- one hour -- greater than the time arbitrarily provided?

@mikhail-rakhmanov what timezone are you in?

UTC+03 Moscow was the issue I changed it, and now test successful.

Thanks for your quick responses. Since the test now passes, I am closing this ticket.

@jkeenan jkeenan closed this as completed Jul 30, 2022
@xenu
Copy link
Member

xenu commented Aug 7, 2022

Perl should work in all time zones. Reopening.

@xenu xenu reopened this Aug 7, 2022
xenu added a commit to xenu/perl5 that referenced this issue Aug 7, 2022
Conversion to local time seems unnecessary and it apparently causes
issues with DST.

Fixes Perl#20018, Perl#20061
@xenu
Copy link
Member

xenu commented Aug 7, 2022

This seems to have the same underlying cause as #20061, so #20064 should fix it.

xenu added a commit that referenced this issue Aug 9, 2022
Conversion to local time seems unnecessary and it apparently causes
issues with DST.

Fixes #20018, #20061
scottchiefbaker pushed a commit to scottchiefbaker/perl5 that referenced this issue Nov 3, 2022
Conversion to local time seems unnecessary and it apparently causes
issues with DST.

Fixes Perl#20018, Perl#20061
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants