Bug 8504 - The private field 'System.DateTime.to_local_time_span_object' isn't updated under certain conditions
Summary: The private field 'System.DateTime.to_local_time_span_object' isn't updated u...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-11-19 10:33 UTC by Greg
Modified: 2013-01-11 11:26 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Greg 2012-11-19 10:33:02 UTC
The following condition in the property 'System.DateTime.Now':

    if ((now - last_now) > TimeSpan.TicksPerMinute){

Should be 

    if (Math.abs(now - last_now) > TimeSpan.TicksPerMinute){

The system time may be changed back in time, in this case the static variable 'DateTime.to_local_time_span_object' will never be updated. I think it's a serious issue.

Github Code reference: https://github.com/mono/mono/blob/2.10.8/mcs/class/corlib/System/DateTime.cs#L460

I guess the same issue occurs here: https://github.com/mono/mono/blob/2.10.8/mcs/class/corlib/System/TimeZone.cs#L75

The only workaround I found instead of using 'DateTime.Now' is: 'TimeZone.CurrentTimeZone.ToLocalTime(DateTime.UtcNow)'.
Comment 1 Rodrigo Kumpera 2013-01-11 11:26:24 UTC
Fixed on master.