Skip to content
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

Unix.stat on Windows returns timestamps which depend on the DST setting #7385

Closed
vicuna opened this issue Oct 14, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Oct 14, 2016

Original bug ID: 7385
Reporter: @nojb
Assigned to: @dra27
Status: resolved (set by @damiendoligez on 2017-06-09T09:11:52Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: Windows
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: otherlibs
Has duplicate: #7569
Related to: #7489
Monitored by: @gasche jmeber @alainfrisch

Bug description

Unix.stat on Windows returns different time stamps (notably the st_mtime field) depending on the DST setting of the machine on which it is executed.

For reference, Unix.stat on Un*x returns an absolute timestamp which is completely independent of any time zone/DST setting.

This bug appears to have existed for some time (it is at least present in 4.02.0), but of course is hard to spot since the bug causes only a 1hr difference in the resulting timestamp and is only present half the year.

We are currently investigating the source of the bug.

Steps to reproduce

$ ocaml unix.cma

Unix.stat "foo.txt";;

Now, change the DST setting on Windows, repeat the above and see how the timestamps have changed by 1hr.

@vicuna

This comment has been minimized.

Copy link
Author

commented Oct 14, 2016

Comment author: @nojb

Removing the call to FileTimeToLocalFileTime in win32unix/stat.c seems to produce timestamps which do not depend on the current DST setting.

Maybe someone more familiar with this code can shed some light on the use of this function ?

@vicuna

This comment has been minimized.

Copy link
Author

commented Oct 17, 2016

Comment author: @nojb

Continuing discussion at #861 trying to get feedback on possible solution.

@vicuna

This comment has been minimized.

Copy link
Author

commented Feb 20, 2017

Comment author: @dra27

Full explanation in #861 (comment) and see also #1057 for a hopefully complete fix.

@vicuna

This comment has been minimized.

Copy link
Author

commented Feb 20, 2017

Comment author: @dra27

This bug is always present in OCaml 4.03.0 and later. In earlier versions (including your 4.02.0 report) it's present when using Visual Studio 2012 or earlier (it's fixed in msvcr120.dll - Visual Studio 2013).

@vicuna

This comment has been minimized.

Copy link
Author

commented Jun 9, 2017

Comment author: @damiendoligez

Fixed by #1057 in 4.04 (a230e30), 4.05 (4afea74), and trunk (65a492d).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.