• entries
    205
  • comments
    228
  • views
    112811

Worst & Best ever

Sign in to follow this  
Mike Bossy

75 views

I am in the middle of trying to fix one of my worst and best bugs ever. I am still getting a random crash at startup probably 5% of the time. I have narrowed it down to a total race condition somewhere. I believe it's in my messaging system somewhere. I'm also pretty sure it's due to my MIS-use of STL containers which are not thread safe. I am in the process of attempting to control access to my messaging system through mutexes which is going suprisingly well considering how scary it sounds.

So in amongst all this pain is some good. In my hair pulling episodes of trying to track this problem down I've investigated every possibility imaginable and have fixed a tonne of other bugs in the process!

First I thought that it might be a COM issue around DirectSound. I am not a COM wizard but I've had some problems in the past using single threaded apartments and objects getting locked or lost. So I switch to a MTA and in the process found that I had some stray calls to CoInitialize() lying around from a previous refactoring of my resource manager. A couple lines cut out and I magically get a 50% improvement in frame rate!! I still don't understand it. The only thing I can guess is that I had some extra marshalling going on with my textures which meant a lot of extra overhead. Either way 50% is huge! I may now run on lower end machines in a window.

After the COM didn't fix my main problem I went looking for memory leaks/overwrites. This helped me find a few leaks that I didn't know about which is a plus. But more importantly while running using MMGR from Fluid I found some other weird race conditions in my shut down process that got exposed thanks to the mem manager slowing things down differently. This lead me to making my thread shut down more robust.

All in all my engine is now faster, tighter and more robust. If I can only find this random crash I'll be sitting sweet. Here's hoping my mutexes do the trick.
Sign in to follow this  


1 Comment


Recommended Comments

I feel your pain... debugging a 6-threaded realtime network app was one of my most interesting and memorable (if not pleasant) experiences.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now