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

Author Topic: Anoying problem  (Read 15742 times)

0 Members and 1 Guest are viewing this topic.

Regen

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Anoying problem
« on: June 25, 2008, 09:06:07 am »
Hi, I have been playing around with SFML for a while and now I wanted to start up again, so i checked out the tutorials and tested some code. But on the render-window-tutorial i get a wierd error. The program runs smooth until you shut it down, then an error dialoge appears:

"Run-Time Check Failure #2 - Stack around the variable 'App' was corrupted."

I dont thinks you have made a typo, and the code i have is copy-pasted so it must be some setting i have in visual studio 2008 that is wrong?

Thanks for any help in advance!
Why can't things just work?

workmad3

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Anoying problem
« Reply #1 on: June 25, 2008, 09:28:55 am »
I had that for a while... it turned out to be I was linking a bedug build of my program to the release build of the library, which alters memory layouts etc :)

Regen

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Anoying problem
« Reply #2 on: June 25, 2008, 09:52:04 am »
okej, sorry If the is a stuipid question, but how do i solve it?:P
Why can't things just work?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Anoying problem
« Reply #3 on: June 25, 2008, 11:19:23 am »
Just link debug libraries (with "-d" suffix) in debug build. Isn't explained in the tutorial ?
Laurent Gomila - SFML developer

Regen

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Anoying problem
« Reply #4 on: June 25, 2008, 11:22:25 am »
working fine now! But I still wonder, i have never linked the -d libraries, why do I have to do that now?

thanks!

p.s. point taken about the tutorial
Why can't things just work?

workmad3

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Anoying problem
« Reply #5 on: June 25, 2008, 11:52:58 am »
Not sure why you didn't get the problem before. I started with 1.2 (built myself with VS2008) and always had it if I link incorrectly.

I guess it is up to Laurent to reveal if he has added any particularly interesting stuff in debug builds that would cause this now :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Anoying problem
« Reply #6 on: June 25, 2008, 12:16:10 pm »
There are two things to know about it :

1/ It crashes because of different versions of the standard libraries mixed together, so it's always been there and it will always be, with any library you'll use. This is a very common issue.

2/ The behaviour is everything but predictable, it can crash, freeze, format your computer, corrupt the memory in your music player, or work fine depending on what's inside the standard libraries and how you use it. So I'm not surprised you didn't notice it before.
Laurent Gomila - SFML developer

workmad3

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Anoying problem
« Reply #7 on: June 25, 2008, 12:41:24 pm »
About the only extra thing I know is that if you are using collections from the standard library (and sometimes even raw arrays) then a frequent debug feature is for them to be padded so as to detect things like overflows. If these are allocated with the release allocator and then released with the debug destructor (it can happen. Getting the correct destructor called when there are 2 versions in different dlls is difficult to say the least) then the memory appears corrupted because the padding characters aren't correct and you get that lovely error.

Regen

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Anoying problem
« Reply #8 on: June 27, 2008, 03:18:21 pm »
Something wierd just happend, i was working on another project, then i went back to my old code (the one that before had problems) and now it doesnt work! i have not done a thing with it....
this time the error message is:
"Run-Time Check Failure #2 - Stack around the variable 'State' was corrupted."

And this time i have linked to the "-d" libs! :(

edit: Probably I have done something to it but just dont remember:P
Why can't things just work?

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Anoying problem
« Reply #9 on: June 27, 2008, 03:35:56 pm »
Try to rebuild the whole project.

Regen

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Anoying problem
« Reply #10 on: June 27, 2008, 03:38:06 pm »
ofcourse tried that, even tried it all in VS2005 to (wanted to test some other stuff there aswell)
Why can't things just work?

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Anoying problem
« Reply #11 on: June 27, 2008, 03:55:13 pm »
It could be a code related problem.
Maybe a buffer overflow.
Make sure that all pointers point to a valid location.

Regen

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Anoying problem
« Reply #12 on: June 30, 2008, 08:08:03 am »
dont think it is, the code is the same as before (when it worked) must be some settings that's screwed up, I'l keep on testing foreward.

edit: The most annoying thing now is that the application wont start at all, before I atleast got the error message after closing it:(

edit again: Can't get this to work:(
Why can't things just work?

workmad3

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Anoying problem
« Reply #13 on: June 30, 2008, 12:00:06 pm »
have you done something like build a release build of your code with the debug libraries linked this time?

Regen

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Anoying problem
« Reply #14 on: June 30, 2008, 12:20:19 pm »
nope, building debug with debug libraries:(

edit: for some reason i cant create either a renderwindow or a "normal" window at all in any way, in any project.....get the same error:(

Even this code:
#include <SFML/WINDOW.HPP>

int main() {

   sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

   return 0;
}
 :(
Why can't things just work?