This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 42688 - Can't wait for more than 429496 ms (429s)
Summary: Can't wait for more than 429496 ms (429s)
Status: VERIFIED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: 4.4.0 (C7)
Hardware: PC Mac OS
: Highest critical
Target Milestone: (C7)
Assignee: Rodrigo Kumpera
URL:
: 41701 42295 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-07-20 13:26 UTC by Rolf Bjarne Kvinge
Modified: 2016-07-29 14:25 UTC (History)
9 users (show)

See Also:
Tags: DefectEscapeReview_Done
Is this bug a regression?: Yes
Last known good build: 4.2


Attachments

Description Rolf Bjarne Kvinge 2016-07-20 13:26:56 UTC
Test case:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
		var ts = TimeSpan.FromMilliseconds (429497);
		var mre = new ManualResetEvent (false);
		var watch = new Stopwatch ();
		watch.Start ();
		var rv = mre.WaitOne (ts, false);
		watch.Stop ();
		Console.WriteLine ("Tried to wait for {0}s and waited only for {1}s result: {2}", ts.TotalSeconds, watch.Elapsed.TotalSeconds, rv);
    }
}

Running this exits pretty much instantly with:

$ mono test.exe
Tried to wait for 429.497s and waited only for 0.0001574s result: False

The problem is here https://github.com/mono/mono/blob/f136599a685a26f467bd8f5a1b0c98b6af65c779/mono/io-layer/wait.c#L143:

		end = mono_100ns_ticks () + timeout * 1000 * 10;

when timeout > 429496 the multiplication overflows and wraps around.

I can reproduce both with mono master and current stable:

$ mono --version
Mono JIT compiler version 4.4.1 (mono-4.4.0-branch-c7sr0/4747417 Mon Jun 20 15:43:48 EDT 2016)
Comment 1 Rolf Bjarne Kvinge 2016-07-20 13:28:58 UTC
Raising importance since this is a regression.
Comment 2 Rolf Bjarne Kvinge 2016-07-20 13:30:10 UTC
Ludovic, this seems to have been introduced with https://github.com/mono/mono/commit/55492cbbee242e6fc844863c6360411e77ae3c52.
Comment 3 Rodrigo Kumpera 2016-07-20 17:51:01 UTC
https://github.com/mono/mono/pull/3306
l
Comment 4 Rodrigo Kumpera 2016-07-21 01:31:41 UTC
Fixed on mono 4.4.0, 4.6.0 and master.

Now pushing PRs to bump the products.
Comment 5 Shruti 2016-07-21 11:11:46 UTC
***************************
Reproduce Status:
***************************
I am able to reproduce this issue with above stable Mono 4.4.1 (mono-4.4.0-branch-c7sr0/4747417) (64-bit) and got following result:
 Tried to wait for 429.497s and waited only for 0.0009798s result: False

Screencast: http://www.screencast.com/t/6kqcIlLc

***************************
Verify Status: C7SR1
***************************
I have checked this issue with mono-4.4.0-c7sr1 (revision e4b69ff6df35788d03bacb507af05369bc42ae73) and observed that now its waiting for 429s. Now, I am getting following result
Tried to wait for 429.497s and waited only for 429.4981815s result: False

Screencast: http://www.screencast.com/t/Buz16wHSJ
Environment Info:https://gist.github.com/shrutis360/d18d132d5e9f072fb5509fa24e1c71b9

***************************
Verify Status: Master
***************************
Working fine with latest master MonoFramework-MDK-4.5.2.770 and got following result
Tried to wait for 429.497s and waited only for 429.5034533s result: False 

mono-4.4.0-branch: a7de69bbcd02d16f259e88217176931dd81c1853 is not build yet on wrench so not able to verify this issue here.
On above behaviour of C7SR1 and Master, I changing bug status as 'Verified' and will verify the bug on C7 mono-4.4.0-branch once get build successfully.
Comment 6 Ludovic Henry 2016-07-22 22:00:51 UTC
*** Bug 41701 has been marked as a duplicate of this bug. ***
Comment 7 Ludovic Henry 2016-07-22 22:01:17 UTC
*** Bug 42295 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.