Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Crashing on exit, Release build only.  (Read 2202 times)

0 Members and 1 Guest are viewing this topic.

Wertle

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Crashing on exit, Release build only.
« on: March 27, 2012, 10:40:43 am »
Well i've been fighting this problem for a few days and haven't been able to track down anything similair on these forums or google so here is my cry for help.

I'm using MSVS C++ 2010 and compiled the SFML 2.0 build a few days ago. It was the first time i've compiled it so it is possible I got something wrong, though after a few attempts and video tutorials I think I have that sorted. I'm also running Windows 7 64bit, but it is an x86 install of VS.

In debug mode my game works perfectly fine. For the release build however the game crashes upon exiting. While it doesn't effect gameplay it is frustrating.
 
This is the error I get "Unhandled exception at 0x768f4dcc in BrickOut.exe: 0xC0000005: Access violation reading location 0xfeeefeee."

If I stop it has the break point at line 518 in crtexe.c

If I comment out the sf::SoundBuffer and sf::Sound related code then everything runs normally, though without sound of course (audio is the only package that i'm currently trying to integrate).

The code for the game is well in excess of 6000 lines so i'll just post the examples of the SFML code as it is written in my code. Though i'm not sure how helpful it'll be as I have this problem even if I comment out everything except one sfml declaration.

// SFML Includes
#include <SFML/Audio.hpp>

...

sf::SoundBuffer bufferBrickKO;

...

sf::Sound soundQueue[SOUNDQUEUESIZE];                (constant is set to 25 for now)
   
...

void initSound() // Initialise the sound buffers and the sound queue
{
    if(!bufferBrickKO.loadFromFile(SOUND_BRICKKO))
    {
        MessageBox(NULL, "KO Sound Not Loaded", NULL, NULL);
        soundLoaded = false; // Sound failed to load
    }
    ...
}

...

void AddSound(std::string sound) // Create a sound for the given sound buffer and add it to the queue
{
    int n; // Counter

    // Find the last free sound position in the queue
    n = 0;
    while(n < SOUNDQUEUESIZE)
    {
        if(soundQueue[n].getStatus() == sf::Sound::Status::Stopped) // Found an empty position
        {
            if(sound == SOUND_BRICKKO)
            {
                soundQueue[n].setBuffer(bufferBrickKO);
            }
            ...

            soundQueue[n].play();
            break;
        }
        n++;
    }
}
« Last Edit: March 27, 2012, 01:35:50 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Wertle

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Crashing on exit, Release build only.
« Reply #2 on: March 27, 2012, 11:53:44 am »
It may be related to that also. I'm guessing that it's still being worked on in that case.

I'll try to figure out building the static libraries this week and see if they work as mentioned in the comments there.

Wertle

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Crashing on exit, Release build only.
« Reply #3 on: March 28, 2012, 11:40:08 am »
Thanks for that link Laurent. Finally figured out how to use the static libs properly and I don't have the error. It's a bit of a shame as I was looking forward to using dlls but that something to look forward to on future releases.

 

anything