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

Author Topic: sf::RenderTexture destructor causes a crash  (Read 13688 times)

0 Members and 3 Guests are viewing this topic.

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
sf::RenderTexture destructor causes a crash
« on: October 05, 2013, 03:01:57 am »
Hello, i noticed a very strange error when the sf::RenderTexture destructor is called.
Take a look at this example, the application crashes (on Visual Studio) with:
"Windows has triggered a breakpoint in "ApplicationName". This may be due to a corruption of the heap, which indicates a bug in "ApplicationName" or any of the DLLs it has loaded."
Code: [Select]
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");


sf::RenderTexture* renderTexture = new sf::RenderTexture();
renderTexture->create(32, 32);
//stuff
delete renderTexture;



while (window.isOpen())
{
window.clear();
window.display();
}

return 0;
}

But if before the destructor call i write for instance: 'window.clear()' or 'window.display()' there isn't any crash.
« Last Edit: October 05, 2013, 01:34:01 pm by wogoo »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: sf::RenderWindow destructor causes a crash
« Reply #1 on: October 05, 2013, 03:22:10 am »
On my system that code runs perfectly fine, aside from the window being unresponsive due to the lack of an event loop.  The only thing that comes to my mind is: any chance you mixed up debug/release binaries?

Also, you said "renderwindow" in the topic rather than "rendertexture."
« Last Edit: October 05, 2013, 03:23:46 am by Ixrec »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: sf::RenderWindow destructor causes a crash
« Reply #2 on: October 05, 2013, 05:56:41 am »
What's your OS and graphics card?
Are you using the latest driver (don't guess check the website)? ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::RenderWindow destructor causes a crash
« Reply #3 on: October 05, 2013, 09:59:08 am »
Makes sure that you're not mixing VS versions or debug/release.
Laurent Gomila - SFML developer

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #4 on: October 05, 2013, 01:48:29 pm »
For this test i created a new project following exactly the SFML tutorial on this website.
I've used SFML for years and the problem happened only when i started to use RenderTexture, after some testing today i think actually the sf::RenderTexture::Create function mess up the memory, i get different crashes also on sf::Texture desctructor after creating a RenderTexture.

I have the first generation Intel HD Graphics on Windows7, and there isn't any driver update available.

Edit:
With different graphic cards i don't get this behaviour, and it works perfectly.
« Last Edit: October 05, 2013, 03:42:15 pm by wogoo »

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #5 on: October 06, 2013, 05:22:28 pm »
I would be glad to donate to SFML if this issue will be solved, i'm working on an important project and without a fix i'm forced to switch to SDL.

I've done some additional tests with Visual Studio 2010 express/professional (with static and dynamic version) and i obtain the same error, with SFML2.0 also the RendeTexture constructor causes a crash with debug libraries.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #6 on: October 06, 2013, 05:57:44 pm »
Can you upload your Visual Studio project?
Laurent Gomila - SFML developer

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #7 on: October 06, 2013, 06:26:43 pm »
Sure i can, here's the project (Visual Studio 2010 Express), thank you.
https://dl.dropboxusercontent.com/u/43781201/stuff3/TestRenderTexture.rar

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #8 on: October 06, 2013, 09:39:02 pm »
Thanks but I don't think I needed to download SFML, your compiled files, precompiled header, etc. Just your project file (a few KB, compared to your 16 MB archive) :P

Nothing seems to be wrong. You downloaded the VC++ 10 SDK of SFML, right?
Laurent Gomila - SFML developer

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #9 on: October 06, 2013, 10:15:11 pm »
Yes i do, i tried also with the 2.0 version.
I'm sure that it's a memory issue, for my project sometimes i don't get the crash if i load a certain number of textures before, or i get the crash only in debug/release mode, inside/outside the editor and so on.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Re: sf::RenderTexture destructor causes a crash
« Reply #10 on: October 07, 2013, 09:59:54 pm »
What graphics hardware does this crash on? Intel are famous for poor OpenGL driver support, I am sure any problems are because of this.

We have our SFML apps on roughly 50,000 industrial PC systems using different hardware, running ~18 hrs a day, every day, and no problems - except for systems with Intel drivers where we've had to make so many changes to get it stable.
SFML 2.1

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #11 on: October 07, 2013, 10:20:56 pm »
@slotdev: I know this is off-topic, but I'm extremely curious now: What are these SFML programs you have running on tens of thousands of computers?  I always thought business/industrial programs would be more likely to use a library with advanced GUI features.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #12 on: October 07, 2013, 10:25:13 pm »
@slotdev: I know this is off-topic, but I'm extremely curious now: What are these SFML programs you have running on tens of thousands of computers?  I always thought business/industrial programs would be more likely to use a library with advanced GUI features.

I believe he has stated before he writes games that are deployed on slot machines (hence his name).
« Last Edit: October 07, 2013, 10:29:11 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #13 on: October 08, 2013, 04:20:22 pm »
What graphics hardware does this crash on? Intel are famous for poor OpenGL driver support, I am sure any problems are because of this.

We have our SFML apps on roughly 50,000 industrial PC systems using different hardware, running ~18 hrs a day, every day, and no problems - except for systems with Intel drivers where we've had to make so many changes to get it stable.
Yes it's certainly this kind of issue, the graphics card i have is a custom version of Intel HD Graphics and for most of 3D games for example i need to switch to my second computer in order to play. This computer however is not powerful enough for my work.
Anyway, the crashes happen on a simple framebuffer and i think there is a way to fix it.

wogoo

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: sf::RenderTexture destructor causes a crash
« Reply #14 on: October 10, 2013, 07:40:09 pm »
So Laurent do you think this issue can be solved?
If you want i can test some code on my computer, or whatever you need.

Sincerely i haven't much time to switch to another framework right now, and also i think SFML is better that other C++ "competitors".