# SFML crash when debugging, but ok on release.

This topic is 1817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I tried to search regarding this problem on google but couldn't find a similar case. The problems I found is vice versa of mine - crash when release but ok when debugging.

I already checked my project's configuration a dozen times but still can't find whats wrong.

##### Share on other sites

In what way is it crashing?

My first guess is that it's because of uninitialized data. The value of the unintialized data will be different in release and debug, and might make one of the cases crash.

My second guess is misuse of some pointer that either writes outside a buffer, or in already freed memory. That could also lead to one case crashing and the other not.

In both cases it can go either way, release working and debug crashing, or debug working but release crashing.

##### Share on other sites

For SFML another possibility is that you've linked to the release version of the library in debug mode.

##### Share on other sites

In what way is it crashing?

Thanks for replying. The crash is that, it just produce white blank window. And when I try to click the window, it wouldn't respond (like when trying to click 'x' button to close the window). Also, this doesn't happen before I changed the code a bit. After I received this crash, I undo the changes I had made, but still get the crash. Why did this happen?

For SFML another possibility is that you've linked to the release version of the library in debug mode.

I don't think so.

Under my Configuration -> Debug -> Linker -> Input -> Additional dependencies:

sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib

If I'm not mistaken, "-d" for debug, without the "-d" for release.

Also, I just realised I got this output when debugging:

'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dinput.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\hid.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wintrust.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\crypt32.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msasn1.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\apphelp.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
[...and the lists of similar kind of error goes on...]

I hope this can give you the clue to find what causes this crash. Thanks for the reply really appreciate it.

##### Share on other sites

I also got this, is this important?

'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Users\Amirul\Documents\Visual Studio 2012\Projects\Dragon Villa SFML\Dragon Villa SFML\sfml-graphics-d-2.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Users\Amirul\Documents\Visual Studio 2012\Projects\Dragon Villa SFML\Dragon Villa SFML\sfml-window-d-2.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Users\Amirul\Documents\Visual Studio 2012\Projects\Dragon Villa SFML\Dragon Villa SFML\sfml-system-d-2.dll'. Cannot find or open the PDB file.

##### Share on other sites

Here's my general process for solving these kinds of problems:

Step 1: "Rebuild all". This might fix your problem on its own.

Step 2: Scatter a few breakpoints around areas where you think the crash is occurring.

Step 3: Run your debugger, and when you hit a debugger, start stepping through the code (using your debugger's 'step' feature) bit by bit until it reaches the point where it crashes. This is how you know what line is causing the crash.

Step 4: Find out why that line is crashing. Is a pointer uninitialized? Are you dividing by zero? Was the object already destroyed?

Step 5: Fix the problem. If you need help with that part, after you've already found the cause of the problem, then show us the part that's crashing, and we might have a few ideas if, by that point, you haven't already solved it yourself - which is usually the case.

It's also not a bad idea to occasionally run your code through a static analyzer like cppcheck. Static analyzers read your code, without compiling it, and look for common mistakes that compile fine but don't work fine.

##### Share on other sites

In what way is it crashing?

Thanks for replying. The crash is that, it just produce white blank window. And when I try to click the window, it wouldn't respond (like when trying to click 'x' button to close the window). Also, this doesn't happen before I changed the code a bit. After I received this crash, I undo the changes I had made, but still get the crash. Why did this happen?

For SFML another possibility is that you've linked to the release version of the library in debug mode.

I don't think so.

Under my Configuration -> Debug -> Linker -> Input -> Additional dependencies:

sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib

If I'm not mistaken, "-d" for debug, without the "-d" for release.

Also, I just realised I got this output when debugging:

'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dinput.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\hid.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wintrust.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\crypt32.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msasn1.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\apphelp.dll'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
'Dragon Villa SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cmd.exe'. Cannot find or open the PDB file.
'Dragon Villa SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\cmd.exe'
[...and the lists of similar kind of error goes on...]

I hope this can give you the clue to find what causes this crash. Thanks for the reply really appreciate it.

Anytime I get a white screen it is because I am missing a .dll in the folder.

##### Share on other sites

start stepping through the code (using your debugger's 'step' feature)

Lol thanks for introducing me to this interesting feature. i wouldn't know this exist.

Anyway i tried it out and found out that in main:


TEXT.Set_Fonts(); // problem avoided when I commented this out and came back when I uncomment this
TEXT.Set_Texts();



So I guess that is the root of the problem. But I couldn't figure out why is it so.

//in Texts.cpp

void Texts::Set_Fonts()
{
{
for(int i = 0; i < 10; i++)
{
text[i].setFont(font);
promptedText[i].setFont(font);
}

FPS.setFont(font);

}
else
{
std::cout << "Failed to load fonts " << std::endl;
system("pause");
}

}


##### Share on other sites

Did you step through ("step into") that function also?

My guess is that this part of the documentation might be causing some difficulty.

The sf::Text only keeps a pointer to the sf::Font. You have to make sure the sf::Font stays around for longer than the sf::Texts are in use.

Edited by Servant of the Lord

##### Share on other sites

I figured out the problem. It was really a silly mistake. I made the array promptedText[] to have a size of 2 elements ( I should make it at least 10 ) and I forgot to change it to 10 . Really silly mistake.. But this make me wonder why it gives a green light on release.

Oh well I got it now. Thanks man

Edited by Meerul264

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002032
×