[Mono-bugs] [Bug 387962] New: Exception when working with Timers heavily

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed May 7 16:07:08 EDT 2008


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


           Summary: Exception when working with Timers heavily
           Product: Mono: Class Libraries
           Version: 1.9.0
          Platform: x86
        OS/Version: openSUSE 10.3
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: davecferguson at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Integration Test


Created an attachment (id=213297)
 --> (https://bugzilla.novell.com/attachment.cgi?id=213297)
Sample application to reproduce exception

Description of Problem:

We are building an application that starts and stops timers quite often. 
Occasionally, we will see marked delays and then an unhandled exception thrown
for no reason.  It seems to be a timing issue and is happening within the
runtime itself.  At this point, our test app is only able to replicate the
issue with the System.Timers.Timer.  We wrote a facade around the
System.Threading.Timer and are testing that at the moment. 


Steps to reproduce the problem:
1. Create many System.Timers.Timer objects with a fairly quick interval
2. Start and stop them from several different threads (randomly).
3. In the Elapsed event, stop and start the timer that raised the event.


Actual Results:

Here's an excerpt of the output of our test app:

Expired at: 5/7/2008 1:22:50 PM -810730304
Expired at: 5/7/2008 1:22:50 PM 226709824
Starter Expired at: 5/7/2008 1:22:50 PM
Starter Expired at: 5/7/2008 1:22:50 PM
Starter Expired at: 5/7/2008 1:22:50 PM
Expired at: 5/7/2008 1:22:50 PM 273009792
Starter Expired at: 5/7/2008 1:22:52 PM
Starter Expired at: 5/7/2008 1:22:52 PM
Starter Expired at: 5/7/2008 1:22:53 PM
Terminating: True
System.NullReferenceException: Object reference not set to an instance of an
object
  at System.Timers.Timer.StartTimer () [0x00000] 
prof counts: total/unmanaged: 1704/1703
   1536 90.19 % 
     32  1.88 % /lib/libc.so.6(semop
     17  1.00 % mono(_wapi_handle_timedwait_signal_handle
     13  0.76 % mono(WaitForSingleObjectEx
     11  0.65 % /lib/libc.so.6(clone
     10  0.59 % mono(_wapi_handle_ops_prewait
      8  0.47 % mono(own_if_signalled

The output above was for 30 timers firing every 100 milliseconds (stopping and
restarting themselves...Autoreset was not set).  In addition, a thread would
stop and start all timers every 1 second.

A similar event happens with only 2 timers firing every 100 milliseconds (no
Autoreset, but restarting in the Elapsed event).  See TimerTimerTest.cs in the
attached sample application.

You can see that even before the second thread stopped and started timers,
there were issues with the timers firing their events appropriately.


Expected Results:

A steady stream of output from the timers expiring on time and with no
exceptions.

How often does this happen? 

Able to reproduce almost 95% of the time with attached test application.


Additional Information:

Use the following command line parameters with the test application:

interval=100 count=2 resetinterval=1000 oneshot=true type=timer


-- 
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