• Announcements

GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Followers 0

SFML crash when debugging, but ok on release.

13 posts in this topic

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.

0

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.

0

Share on other sites

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

0

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.
0

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.
0

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.

0

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.

0

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");
}

}

0

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
0

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
0

Share on other sites

Yeah, that kind of mistake occurs alot. Part of programming is learning good practices that reduces or removes those kind of mistakes.

Two solutions:

1) Don't use "magic numbers" in your code. '10' in your code doesn't mean anything, and neither does '2'. Changing them in one place requires you to remember changing them in other places (sometimes dozens). Instead, it's much better to replace magic numbers with well-named constant variables. Changing the constant's value automaticly makes all the code that uses the constant still work properly.

Example:

//The value is only set once, in a specific location.
const int PROMPTED_TEXT_COUNT = 10;

//In one location:
sf::Text promptedText[PROMPTED_TEXT_COUNT];

//In another location:
for(size_t i = 0; i <  PROMPTED_TEXT_COUNT; i++) { ... }

2) You could make it a std::vector. Or, if you're using C++11, you could make it a std::array. std::vectors keep track of their size as part of their class, and can still be accessed through the [] subscript operator during for() loops, and can also be used with vector.at(n) which double-checks that that location is valid before accessing.

Your for-loop would then look like:

//If you're using C++11's new range-for() syntax:
for(sf::Text &text : promptedText)
{
text.setFont(font);
}

//If you're not using C++11's range-for():
for(size_t i = 0; i < promptedText.size(); i++)
{
promptedText[i].setFont(font);
}

I'd also make sure "text[i].setFont(font);" and  "promptedText[i].setFont(font);" are in different for()-loops, unless you're 100% confident that they will always forever have the same number of elements as each other.

Edited by Servant of the Lord
0

Share on other sites

//If you're not using C++11's range-for():
for(int i = 0; i < promptedText.size(); i++)
{
promptedText[i].setFont(font);
}


You are using promptedText.size(). Doesn't that require promptedText.push_back(sf::Text &) first? Is this possible if I were to initialise the font of this text before i begin the game loop (i.e before window is open) ?

Or you are saying that I have to implement the std::vector's reserve() or resize() first?

Edited by Meerul264
0

Share on other sites

Oh, yes, most certainly resize to the correct size first. I was (incorrectly) assuming your code was already doing that in your existing array elsewhere.

0

Share on other sites

I see. Thanks again :)

0

Create an account

Register a new account

Followers 0

• 28
• 13
• 11
• 31
• 20