Null Reference Exception

Jul 13, 2012 at 6:15 PM
Edited Jul 13, 2012 at 6:16 PM

I seem to randomly get a null reference exception at the following line of IGF

public sealed class Interpolator    {        // ReSharper disable StaticFieldInitializersReferesToFieldBelow        private static readonly Pool<Interpolator> Interpolators = new Pool<Interpolator>(10, i => i._valid)

as my game starts - the fact that it happens randomly leads me to believe it's some sort of race condition - the error occurs within the first few frames of the introduction game state starting (i'm using the introduction gamestate code from AOS and have only really changed the splash screen to my own at the moment) - I've not really investigated this much so far since i've been concentrating on the actual game and since it's an occasional error it hasn't bothered me too much, but thought i'd post a quick message here to see if anyone else has seen this issue ?

edit- i should really have mentioned that the error is caused because i is null

Coordinator
Jul 16, 2012 at 7:26 PM

Hi bamyazi,

It did happen to me too and never got around this issue except that this doesn't seem to be reproducable on release mode. Could you try it yourself and see if that is the case for you too?

Thanks

Jul 17, 2012 at 10:36 AM

Yes it happens regardless of debug/release on PC and XBOX and occurs considerably more frequently on XBOX if i run the game outside of GS Connect - I'll post back here when i get to the bottom of it.

Jul 18, 2012 at 12:49 AM

Still not nailed this one yet - it happens when Cleanup is called on the Interpolators and the VALID/INVALID counts appear to be out of sync so that it calls the validate callback for an interpolator when they are all null and always seems to happen with the very first one created. It's a bit of a pain to track down since it's intermittant - i've got a load of debug output running now so hopefully i should figure it out soon.