mnubbe/rope — Issue #1: Physics FPS counter invokes exception
Author: mnubbe
Created: 2011-12-20 06:05:29+00:00
State: open

Suspected problem: as GetFPS iterates through the ringbuffer in a foreach loop, something adds an element. As the Physics FPS counter is in another thread, they can occasionally sync to cause this exception. Happens randomly, maybe once per 5 minutes. My use of lock() does not prevent it, meaning (most likely) that I do not understand lock() or (much less likely) this is getting around lock().

Callstack (note line 3 in code):

ClassLibrary1.Collections.Generic.RingBuffer`1+c__Iterator0[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext () in /home/mnubbe/git/rope/src/ringbuffer.cs:141
Statistics.Stats.GetFPS (name="Physics") in /home/mnubbe/git/rope/src/stats.cs:73
Canvas.DrawHUD () in /home/mnubbe/git/rope/src/canvas.cs:308
Canvas.OnRenderFrame (e={OpenTK.FrameEventArgs}) in /home/mnubbe/git/rope/src/canvas.cs:194
OpenTK.GameWindow.OnRenderFrameInternal (e={OpenTK.FrameEventArgs}) in
OpenTK.GameWindow.RaiseRenderFrame (render_watch={System.Diagnostics.Stopwatch}, next_render=-1, render_args={OpenTK.FrameEventArgs}) in
OpenTK.GameWindow.DispatchUpdateAndRenderFrame (sender={Canvas}, e={System.EventArgs}) in
OpenTK.GameWindow.Run (updates_per_second=30, frames_per_second=0) in
Rope.Start () in /home/mnubbe/git/rope/src/rope.cs:28
EntryPoint.Main () in /home/mnubbe/git/rope/src/rope.cs:85