Bug 6438 - System.Threading.Timer bug - adding duplicate item to sortedlist - seen intermittently with mono 2.10.x
Summary: System.Threading.Timer bug - adding duplicate item to sortedlist - seen inter...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-08-07 07:10 UTC by Iain
Modified: 2013-01-09 15:39 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 for Bug 6438 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Iain 2012-08-07 07:10:00 UTC
We get the below stacktrace sometimes when changing a timer (Mono 2.10.x).  
Problem is intermittent and hard to reproduce.  Seen it mostly on mac and also I think I recall seeing it on android too.

I suspect it could be related to this commit?


Unfortunately I can't find bug #648130 to see why list.IndexOfKey is a no-no for the Scheduler.Add method, but I notice that IndexOfKey is still being used in Scheduler.InternalRemove.  Is that possibly the problem?

Anyway, here's the stacktrace we get:

System.ArgumentException: Key 'System.Threading.Timer' already exists in list.
  at System.Collections.SortedList.PutImpl (System.Object key, System.Object value, Boolean overwrite) [0x00000] in <filename unknown>:0 
  at System.Collections.SortedList.Add (System.Object key, System.Object value) [0x00000] in <filename unknown>:0 
  at System.Threading.Timer+Scheduler.Add (System.Threading.Timer timer) [0x00000] in <filename unknown>:0 
  at System.Threading.Timer+Scheduler.Change (System.Threading.Timer timer, Int64 new_next_run) [0x00000] in <filename unknown>:0 
  at System.Threading.Timer.Change (Int64 dueTime, Int64 period, Boolean first) [0x00000] in <filename unknown>:0 
  at System.Threading.Timer.Change (Int64 dueTime, Int64 period) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Threading.Timer:Change (long,long)