[Mono-bugs] [Bug 468570] New: Arithmatic overflow in System.Diagnostics.Stopwatch causes Elapsed property to return a negative timespan after the 25'th hour of running

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jan 22 14:02:03 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=468570


           Summary: Arithmatic overflow in System.Diagnostics.Stopwatch
                    causes Elapsed property to return a negative timespan
                    after the 25'th hour of running
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.0.x
          Platform: Macintosh
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: silver83 at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Other


Description of Problem:
There is a bug in Stopwatch class causing an arithmetic overflow after the 25th
hour of running.
As a result, the result of the "Elapsed" property is corrupt.

Steps to reproduce the problem:
1. Start a stopwatch
2. Print the value of Elapsed property every hour
3. Wait 26 hours

Actual Results:
.. (first 22 hours)
23.00.00.0084590
1.00:00:00.0084720
1.01:00:00.2985770
-1.01:00:00.2985770
-1.00:00:00.9041870
-23:14:26.9282570

Expected Results:
.. (first 22 hours)
23.00.00.0084590
1.00:00:00.0084720
1.01:00:00.2985770
1.02:00:00.2985770
1.03:00:00.9041870
1.04:00:00.9282570

How often does this happen? 
Always

Additional Information:
In Stopwatch.cs, need to change the following -
(Timespan.TicksPerSecond * ElapsedTicks / Frequency) 
to 
(ElapsedTicks / (Frequency / Timespan.TicksPerSecond))

and 
(1000 * ElapsedTicks / Frequency)
to 
(ElapsedTicks / (Frequency / 1000))

Don't know how to join as a developer so I'm leaving it up to you to manually
patch things up.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list