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

Author Topic: Possible bug in ... something?  (Read 2876 times)

0 Members and 1 Guest are viewing this topic.

Aval

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Possible bug in ... something?
« on: August 19, 2011, 11:01:20 pm »
Upon closing a program, SFML causes an access violation in certain situations with sf::Texture. I'm using 64-bit Windows 7 and Visual Studio 2010. In VS, at program close, I get

Quote

"First-chance exception at 0x773532d0 in Test.exe: 0xC0000005: Access violation reading location 0x000008bcd188e2f8."
The thread 'Win64 Thread' (0x48c) has exited with code 0 (0x0).
The program '[4896] Test.exe: Native' has exited with code 0 (0x0).


The following code is a pretty good demonstration:

Code: [Select]

#define SFML_DYNAMIC
#include <SFML/Graphics.hpp>

#define ACCESS_VIOLATION

int main()
{
#ifdef ACCESS_VIOLATION
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Title");
#endif

    sf::Texture Texture1;
    if (!Texture1.LoadFromFile("sprite1.png"))
        return EXIT_FAILURE;

sf::Texture Texture2;
    if (!Texture2.LoadFromFile("sprite2.png"))
        return EXIT_FAILURE;

#ifdef ACCESS_VIOLATION
App.Close();
#endif
    return EXIT_SUCCESS;
}


The following code has the same behavior, which is confusing:

Code: [Select]

#define SFML_DYNAMIC
#include <SFML/Graphics.hpp>

#define ACCESS_VIOLATION

int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Title");

    sf::Texture Texture1;
    if (!Texture1.LoadFromFile("sprite1.png"))
        return EXIT_FAILURE;

sf::Texture Texture2;
#ifdef ACCESS_VIOLATION
    if (!Texture2.LoadFromFile("sprite2.png"))
        return EXIT_FAILURE;
#endif

App.Close();
    return EXIT_SUCCESS;
}


Commenting out the #define ACCESS_VIOLATION results in no error.

Aval

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Possible bug in ... something?
« Reply #1 on: August 20, 2011, 02:34:48 pm »
I feel silly. http://www.sfml-dev.org/forum/viewtopic.php?t=5613 is talking about the same thing.

I think as long as the textures are destroyed before sf::RenderWindow::Close() is called, it's all good.