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

File.GetCreationTimeUtc() returns the time last modified, not time created #16974

Closed
ryanching opened this issue Sep 20, 2019 · 9 comments · Fixed by #16999
Closed

File.GetCreationTimeUtc() returns the time last modified, not time created #16974

ryanching opened this issue Sep 20, 2019 · 9 comments · Fixed by #16999

Comments

@ryanching
Copy link

@ryanching ryanching commented Sep 20, 2019

Steps to Reproduce

  1. Create a file that was modified at a time later than it was created.
  2. In a fresh console project, call "File.GetCreationTimeUtc('path/to/file');"
  3. Notice that the function returns the time that the file was last modified rather than the time at which it was created.

Current Behavior

Function returns time file was last modified.

Expected Behavior

Function should return the time the file was created.

On which platforms did you notice this

[X ] macOS
[ ] Linux
[ ] Windows

Version Used:

Mono 6.4.0.198

@Aguilex

This comment has been minimized.

Copy link

@Aguilex Aguilex commented Sep 20, 2019

The VSMac Telemetry Monitor app reports the time of events incorrectly as a result of this bug... while this tool is only for internal use, it does impact us significantly, since we use this monitor for a significant number of VSMac issues.

@marek-safar marek-safar added this to the 2019-08 (6.6.xx) milestone Sep 23, 2019
@marek-safar

This comment has been minimized.

Copy link
Member

@marek-safar marek-safar commented Sep 23, 2019

@steveisok please priority this

@steveisok

This comment has been minimized.

Copy link
Contributor

@steveisok steveisok commented Sep 23, 2019

So, under the hood we call lstat on the file in order to get all the creation/modification details. If the birth time is not set on the file, then we will fall back to the oldest of the two between the last modification and last status change dates.

What's strange is that the birth time is reporting 0 in code, but running stat -f %SB <file> shows a creation date. Once I dig into our interop routine, I'll know a bit more.

@steveisok

This comment has been minimized.

Copy link
Contributor

@steveisok steveisok commented Sep 23, 2019

It looks like this is our culprit:

https://github.com/mono/corefx/blob/65712075da8062eb2d9304104c110185001f8541/src/Native/Unix/System.Native/pal_io.c#L160-L168

While it seems to be a reasonable assumption for some linux versions, osx does track the birth time. I need to validate a change and then I'll post a PR.

akoeplinger added a commit to akoeplinger/mono that referenced this issue Sep 23, 2019
…stem.Native

The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in mono@8f5cef9.

Fixes mono#16974
monojenkins added a commit to monojenkins/mono that referenced this issue Sep 23, 2019
…stem.Native

The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in mono@8f5cef9.

Fixes mono#16974
akoeplinger added a commit that referenced this issue Sep 23, 2019
…stem.Native (#16999)

The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in 8f5cef9.

Fixes #16974
akoeplinger added a commit that referenced this issue Sep 24, 2019
…stem.Native (#17001)

The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in 8f5cef9.

Fixes #16974
@akoeplinger

This comment has been minimized.

Copy link
Member

@akoeplinger akoeplinger commented Sep 24, 2019

@Aguilex this is fixed in Mono 6.6.0.90 from the 2019-08 branch. Do you need the fix in 2019-06 too?

@Aguilex

This comment has been minimized.

Copy link

@Aguilex Aguilex commented Sep 24, 2019

@akoeplinger yes please... since 2019-06 is used for VSM 8.3, it would be good to be able to use the Telemetry Monitor, and have it report time correctly, for any 8.3 investigations the team may need to do in the coming weeks/months. This assumes that the change is low-risk and will not destabilize the product. VSM 8.3 shipped to stable yesterday, so we'd likely ship this fix in a VSM service release, which typically have much shorter test cycles (and no dogfooding or public previews).

cc @slluis

monojenkins added a commit to monojenkins/mono that referenced this issue Sep 24, 2019
…stem.Native

The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in mono@8f5cef9.

Fixes mono#16974
@marek-safar

This comment has been minimized.

Copy link
Member

@marek-safar marek-safar commented Sep 24, 2019

Why the internal Telemetry Monitor app cannot run with 2019-08 Mono?

@Aguilex

This comment has been minimized.

Copy link

@Aguilex Aguilex commented Sep 24, 2019

Why the internal Telemetry Monitor app cannot run with 2019-08 Mono?

it probably can... but afaik, it runs by default with system mono used by VSM. So if we're trying to investigate an issue with VSM 8.3, it'll run with Mono 2019-06, and then the timestamps are going to be wrong.
Again, since this is an internal tool, we can probably give folks instructions for how to run it with a different mono than what VSM is using. Doable, but more complicated for people doing investigations.

Granted, this "investigate VSM 8.3 issue" is a hypothetical... I'm not aware of any instances where this is blocking. So perhaps it's ok to wait until 8.4/2019-08.

@slluis what's your opinion here?

jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Sep 24, 2019
Changes: mono/mono@bfbf823...6d40f13

Context: mono/mono#15646
Context: mono/mono#16689
Context: mono/mono#16759
Context: mono/mono#16824
Context: mono/mono#16918
Context: mono/mono#16974

Improve exception filtering within the debugger.
jonpryor added a commit to xamarin/xamarin-android that referenced this issue Sep 25, 2019
Changes: mono/mono@bfbf823...6d40f13

Context: mono/mono#15646
Context: mono/mono#16689
Context: mono/mono#16759
Context: mono/mono#16824
Context: mono/mono#16918
Context: mono/mono#16974

Improve exception filtering within the debugger.
jonpryor added a commit to xamarin/xamarin-android that referenced this issue Sep 27, 2019
Changes: mono/mono@bfbf823...6d40f13

Context: mono/mono#15646
Context: mono/mono#16689
Context: mono/mono#16759
Context: mono/mono#16824
Context: mono/mono#16918
Context: mono/mono#16974

Improve exception filtering within the debugger.
@slluis

This comment has been minimized.

Copy link
Member

@slluis slluis commented Sep 27, 2019

@Aguilex I think it can wait. We should start testing 8.4 anyway.

jonpryor added a commit to xamarin/xamarin-android that referenced this issue Dec 3, 2019
Changes: mono/api-snapshot@fc50bc4...45a61d9

        $ git diff --shortstat fc50bc4f...45a61d93
         22 files changed, 775 insertions(+), 474 deletions(-)

Changes: mono/cecil@a6c8f5e...a6a7f5c

        $ git diff --shortstat a6c8f5e1...a6a7f5c0
         55 files changed, 818 insertions(+), 530 deletions(-)

Changes: mono/corefx@1f87de3...49f1c45

        $ git diff --shortstat e4f7102b...49f1c453
         38 files changed, 1171 insertions(+), 419 deletions(-)

Changes: mono/linker@ebe2a1f...e8d054b

        $ git diff --shortstat ebe2a1f4...e8d054bf
         137 files changed, 5360 insertions(+), 1781 deletions(-)

Changes: mono/mono@8946e49...18920a8

        $ git diff --shortstat 8946e49a...18920a83
         1811 files changed, 47240 insertions(+), 48331 deletions(-)

Changes: xamarin/xamarin-android-api-compatibility@a61271e...50a3c52

        $ git diff --shortstat a61271e0...50a3c52d
         1 file changed, 2 insertions(+), 791 deletions(-)

Fixes: #3619

Context: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1005448
Context: https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/967582
Context: dotnet/coreclr#26370
Context: dotnet/coreclr#26479
Context: dotnet/corefx#40455
Context: dotnet/corefx#40578
Context: mono/mono#7377
Context: mono/mono#12421
Context: mono/mono#12586
Context: mono/mono#14080
Context: mono/mono#14725
Context: mono/mono#14772
Context: mono/mono#15261
Context: mono/mono#15262
Context: mono/mono#15263
Context: mono/mono#15307
Context: mono/mono#15308
Context: mono/mono#15310
Context: mono/mono#15646
Context: mono/mono#15687
Context: mono/mono#15805
Context: mono/mono#15992
Context: mono/mono#15994
Context: mono/mono#15999
Context: mono/mono#16032
Context: mono/mono#16034
Context: mono/mono#16046
Context: mono/mono#16192
Context: mono/mono#16308
Context: mono/mono#16310
Context: mono/mono#16369
Context: mono/mono#16380
Context: mono/mono#16381
Context: mono/mono#16395
Context: mono/mono#16411
Context: mono/mono#16415
Context: mono/mono#16486
Context: mono/mono#16570
Context: mono/mono#16605
Context: mono/mono#16616
Context: mono/mono#16689
Context: mono/mono#16701
Context: mono/mono#16712
Context: mono/mono#16742
Context: mono/mono#16759
Context: mono/mono#16803
Context: mono/mono#16808
Context: mono/mono#16824
Context: mono/mono#16876
Context: mono/mono#16879
Context: mono/mono#16918
Context: mono/mono#16943
Context: mono/mono#16950
Context: mono/mono#16974
Context: mono/mono#17004
Context: mono/mono#17017
Context: mono/mono#17038
Context: mono/mono#17040
Context: mono/mono#17083
Context: mono/mono#17084
Context: mono/mono#17133
Context: mono/mono#17139
Context: mono/mono#17151
Context: mono/mono#17180
Context: mono/mono#17278
Context: mono/mono#17549
Context: mono/mono#17569
Context: mono/mono#17665
Context: mono/mono#17687
Context: mono/mono#17737
Context: mono/mono#17790
Context: mono/mono#17924
Context: mono/mono#17931
Context: https://github.com/mono/mono/issues/26758
Context: https://github.com/mono/mono/issues/37913
Context: xamarin/xamarin-macios#7005
jonpryor added a commit to xamarin/xamarin-android that referenced this issue Dec 3, 2019
Changes: mono/api-snapshot@fc50bc4...45a61d9

        $ git diff --shortstat fc50bc4f...45a61d93
         22 files changed, 775 insertions(+), 474 deletions(-)

Changes: mono/cecil@a6c8f5e...a6a7f5c

        $ git diff --shortstat a6c8f5e1...a6a7f5c0
         55 files changed, 818 insertions(+), 530 deletions(-)

Changes: mono/corefx@1f87de3...49f1c45

        $ git diff --shortstat e4f7102b...49f1c453
         38 files changed, 1171 insertions(+), 419 deletions(-)

Changes: mono/linker@ebe2a1f...e8d054b

        $ git diff --shortstat ebe2a1f4...e8d054bf
         137 files changed, 5360 insertions(+), 1781 deletions(-)

Changes: mono/mono@8946e49...18920a8

        $ git diff --shortstat 8946e49a...18920a83
         1811 files changed, 47240 insertions(+), 48331 deletions(-)

Changes: xamarin/xamarin-android-api-compatibility@a61271e...50a3c52

        $ git diff --shortstat a61271e0...50a3c52d
         1 file changed, 2 insertions(+), 791 deletions(-)

Fixes: #3619

Context: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1005448
Context: https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/967582
Context: dotnet/coreclr#26370
Context: dotnet/coreclr#26479
Context: dotnet/corefx#40455
Context: dotnet/corefx#40578
Context: mono/mono#7377
Context: mono/mono#12421
Context: mono/mono#12586
Context: mono/mono#14080
Context: mono/mono#14725
Context: mono/mono#14772
Context: mono/mono#15261
Context: mono/mono#15262
Context: mono/mono#15263
Context: mono/mono#15307
Context: mono/mono#15308
Context: mono/mono#15310
Context: mono/mono#15646
Context: mono/mono#15687
Context: mono/mono#15805
Context: mono/mono#15992
Context: mono/mono#15994
Context: mono/mono#15999
Context: mono/mono#16032
Context: mono/mono#16034
Context: mono/mono#16046
Context: mono/mono#16192
Context: mono/mono#16308
Context: mono/mono#16310
Context: mono/mono#16369
Context: mono/mono#16380
Context: mono/mono#16381
Context: mono/mono#16395
Context: mono/mono#16411
Context: mono/mono#16415
Context: mono/mono#16486
Context: mono/mono#16570
Context: mono/mono#16605
Context: mono/mono#16616
Context: mono/mono#16689
Context: mono/mono#16701
Context: mono/mono#16712
Context: mono/mono#16742
Context: mono/mono#16759
Context: mono/mono#16803
Context: mono/mono#16808
Context: mono/mono#16824
Context: mono/mono#16876
Context: mono/mono#16879
Context: mono/mono#16918
Context: mono/mono#16943
Context: mono/mono#16950
Context: mono/mono#16974
Context: mono/mono#17004
Context: mono/mono#17017
Context: mono/mono#17038
Context: mono/mono#17040
Context: mono/mono#17083
Context: mono/mono#17084
Context: mono/mono#17133
Context: mono/mono#17139
Context: mono/mono#17151
Context: mono/mono#17180
Context: mono/mono#17278
Context: mono/mono#17549
Context: mono/mono#17569
Context: mono/mono#17665
Context: mono/mono#17687
Context: mono/mono#17737
Context: mono/mono#17790
Context: mono/mono#17924
Context: mono/mono#17931
Context: https://github.com/mono/mono/issues/26758
Context: https://github.com/mono/mono/issues/37913
Context: xamarin/xamarin-macios#7005
ManickaP pushed a commit to ManickaP/runtime that referenced this issue Jan 20, 2020
…stem.Native (mono/mono#16999)

The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in https://github.com/mono/mono/commit/mono/mono@8f5cef936491e8b20888bbf18d426482c890637c.

Fixes mono/mono#16974

Commit migrated from mono/mono@9b98db9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.