Bug 39017 - NullRef in Time.Start
Summary: NullRef in Time.Start
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 9.4 (iOS 9.2)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Ludovic Henry
Depends on:
Reported: 2016-02-22 21:06 UTC by Grigory (Playtika)
Modified: 2016-02-23 16:01 UTC (History)
3 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 Developer Community or GitHub 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 Grigory (Playtika) 2016-02-22 21:06:00 UTC

System.NullReferenceException: Object reference not set to an instance of an object
  at System.Timers.Timer.set_Enabled (Boolean value) <0x10153e870 + 0x00080> in <filename unknown>:0  (code.cs:1)
  at System.Timers.Timer.Start () <0x10153edd8 + 0x0000f> in <filename unknown>:0  (code.cs:1)

Have no repro, and have no time to prepare it. It is a rare race condition bug.
There is no such bug in .NET version of our game. Bug is mono impl specific.
Comment 1 Ludovic Henry 2016-02-23 16:00:51 UTC
Hello Grigory,

According to the documentation (https://msdn.microsoft.com/en-us/library/system.timers.timer(v=vs.100).aspx#Anchor_10), "Any instance members are not guaranteed to be thread safe.". And, as you reported, your case involve multiple threads accessing the Timer instance method, so it is then in clear violation of the API / Documentation.

Moreover, we imported System.Timers.Timer from referencesource (https://github.com/mono/mono/commit/02782f4a1ad12eb30bf7e55ad091b3643bd50a3a), meaning it's the same implementation as on .NET.

Thank you for your report,

Have a great day,