-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Bad Process.StartTime in .NET Core 3.1 on macOS #66170
Comments
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process Issue DetailsDescriptionThe value returned from Reproduction StepsFollowing [this guidance](dotnet/sdk#22380 (comment), install the following SDKs on macOS:
Create a new console app: test.csproj: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
</Project> Program.cs: using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ConsoleApp1
{
public static class Program
{
public static void Main()
{
var processStartTime = Process.GetCurrentProcess().StartTime.ToUniversalTime();
var utcNow = DateTime.UtcNow;
var delta = utcNow - processStartTime;
Console.WriteLine($"OS Architecture: {RuntimeInformation.OSArchitecture}");
Console.WriteLine($"Framework: {RuntimeInformation.FrameworkDescription}");
Console.WriteLine($"Process.StartTime: {processStartTime:o}");
Console.WriteLine($"DateTime.UtcNow: {utcNow:o}");
Console.WriteLine($"Delta: {delta}");
Console.WriteLine();
}
}
} Run the program under the various runtimes and observe the results. Expected behaviorThe process start time should be very close to Actual behaviorThe output is correct on .NET 6 and 5, but wildly incorrect on .NET Core 3.1 (LTS).
Regression?The symptoms are similar to #19928, but that was resolve very long ago in .NET Core 2.0. That it is working in .NET 5 and 6 might be related to #30241 Known WorkaroundsNo response ConfigurationNo response Other information
|
The bad result also occurs on .NET Core 2.1, but since it's unsupported I expect that won't get resolved. |
I'm running macOS x64 and I get:
|
Thanks @bruno-garcia. I updated the issue to reflect that it only occurs on M1 hardware, not on Intel. |
@danmoseley @jeffhandley before investing time into porting/ensuring that dotnet/corefx#39572 fixes this issue, can you say if this would meet the bar for 3.1 servicing? |
@mattjohnsonpint it is nice to see you around github :-) I am wondering if this is something really blocking you? or can migrate to .NET 6.0 to work around this issue? telling more about your scenario will be helpful here. |
That's curious, it's not obvious to me that dotnet/corefx#39572 is Arm64 specific. |
Hi @tarekgh! I'm working at Sentry now, on their client SDKs with @bruno-garcia. This came up because |
Linking similar Linux issue #64742. |
@jozkee This would be a good servicing candidate because of how it can affect data in production scenarios that @mattjohnsonpint described. Before we bring it to tactics, we'll want to make sure we can reliably reproduce the issue and verify the fix. If feasible, getting validation from @mattjohnsonpint or @bruno-garcia against a local build from a branch would help address other hesitations too. By the way, thanks for the excellent issue submission and minimal repro, @mattjohnsonpint! |
Just wanted to check in on this. Is it planned to be addressed for 3.1 servicing? Thanks. |
I hate to say it, but we have been postponing the fix so long that 3.1 got out of support. Since all supported versions are not affected (thanks to dotnet/corefx#39572 which got included in 5.0), I am going to close the issue. |
Description
The value returned from
System.Diagnostics.Process.StartTime
is wildly incorrect when run on .NET Core 3.1 (runtime 3.1.22) on macOS 12.2.1 with M1 (Apple Silicon / arm64) processor. The problem does not occur on .NET 6.0 or 5.0, nor does it occur on .NET Core 3.1 running on macOS with an Intel (x64) processor.Reproduction Steps
Following this guidance, install the following SDKs on macOS:
Create a new console app:
test.csproj:
Program.cs:
Run the program under the various runtimes and observe the results.
Expected behavior
The process start time should be very close to
DateTime.UtcNow
(delta near zero) in all cases.Actual behavior
The output is correct on .NET 6 and 5, but wildly incorrect on .NET Core 3.1 (LTS).
Regression?
The symptoms are similar to #19928, but that was resolved very long ago in .NET Core 2.0.
That it is working in .NET 5 and 6, might be related to #30241
The text was updated successfully, but these errors were encountered: