• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      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.
Sign in to follow this  
Followers 0
Plethora

crash on exit, something to do with crtexe.c

10 posts in this topic

I'm posting this with some reluctance, as I prefer to figure out these sorts of errors myself, but I'm lost and could use the help.  I recently ported my project from Code::Blocks to MS VS 2010 express.  Things mostly went fine, and after a little bit of work I have my program running just as it did before, except it crashes on exit.

 

The debugger dumps me into a file called crtexe.c, which is a windows file that handles launching (and/or terminating) a program, as far as I can tell based on google results anyway.  I get a message saying I have an unhandled exception at 0x76ff15de (ntdll.dll).

 

Now google searching this topic has shown me that this problem is likely the result of a null pointer hanging out somewhere.  The problem I'm having is that nothing I'm getting back from the debugger is even remotely helpful in tracking it down. As far as I can tell, main() actually does return successfully, which doesn't make sense to my noob brain so maybe I'm wrong.  

 

Anyway, if there is anyone out there who can give me a hint on how I might solve this, I'd be very appreciative.

0

Share this post


Link to post
Share on other sites

Try removing functionality from the program one at a time, until the error stops occurring on exit.

1

Share this post


Link to post
Share on other sites

Usually a exception comes with a bit more of info (show all you've got). Is the debugger stopping in the c runtime? If so, there should be a comment or message near the break location indicating what went wrong.

 

Probably you accessed freed memory or wrote out of bounds somewhere.

1

Share this post


Link to post
Share on other sites

I've been working my way through my program as you've suggested Ectara, so far no luck, but I'll keep at it.  In the mean time...

 

In addition to unhandled exception I get "Access violation reading location 0x000000008".  It dumps me in the c runtime (that's crtexe.c I'm assuming).  This is the code at the break:

 

        __except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
        {
            /*
             * Should never reach here
             */

            mainret = GetExceptionCode();

            /*
             * Note that if the exe is managed app, we don't really need to
             * call exit or _c_exit. .cctor should be able to take care of
             * this.
             */
            if ( !managedapp )
                _exit(mainret);

            if (has_cctor == 0)
                _cexit();
        } /* end of try - except */
0

Share this post


Link to post
Share on other sites

Small offsets from 0 often imply that the application attempted to access the member of a null instance of a class/struct.

Can you point out the exact line in that block where the debugger breaks in?

Edited by Ectara
0

Share this post


Link to post
Share on other sites

Progress!

 

Ok so I've isolated where the problem occurs just by systematically disabling things (thanks ectara, for your earlier suggestion).  I still have a bit of a problem though, as I think I'm failing to understand how something works but I'm not sure what the problem is precisely.  This is going to be SFML specific to some degree unfortunately.  The error occurs as a result of this method:

 

sf::Sprite Menu_Graphics::createTextButton(sf::Sprite buttonSprite, std::string buttonText)
{
    sf::IntRect subRect = buttonSprite.getTextureRect();
    button.create(subRect.width, subRect.height);
    button.clear(sf::Color(255, 255, 255, 0));

    text.setString(buttonText);
    text.setFont(menuFonts[0]);
    text.setColor(sf::Color::Red);
    text.setCharacterSize(20);
    text.setPosition(25, 8);

    button.draw(buttonSprite);
    button.draw(text);
    button.display();

    sf::Sprite toReturn(button.getTexture());
    return toReturn;
}

 

And, in particular, its an issue with the text object, which is an object of class sf::Text (as in, when I remove text from the method, no more error).  Now what I think is relevant is that sf::Text is dependent on sf::Font objects (in this case, the object accessed as menuFonts[0].  A Font object must remain persistent as long as it is being used by a Text object.  I get that just fine, and as my program functions as intended prior to closing then the Font must exist until then.  

 

So this method in particular takes an sf::Sprite and an std::String and returns a sprite with text on it.  This method returns in a method that puts together the entirety of the Menu for my game, within the class Menu_Graphics.  Now, the fonts all exist in a vector (menuFonts) which is a data member of this class.  However, the put together menu, with all its various components, is eventually passed to my programs main Graphics class.  Obviously menuFonts is out of scope once my menu is passed out of the class.  Is it possible this is the problem?

0

Share this post


Link to post
Share on other sites

Just shooting in the dark here, but this happened to me when a library I was using was not built using the Unicode font set, while my game used the Unicode font set. It too would go and crash in a string related part of my library that was actually perfectly alright. Do try and recompile the library you are using so that both the main program as well as the library are using the same font set.

 

Hope this helps!

~Bollu

Edited by bollµ
0

Share this post


Link to post
Share on other sites

While bollu's idea could be true, are you also making sure your resources are all loaded? In particular is your font loading? I know SFML gives an example for exiting if your resource doesn't load, try using that if you are not.

0

Share this post


Link to post
Share on other sites

It could be a destruction order issue if you have any non-POD global or static objects. It's usually best to heap allocate them so you get control of the destruction order.

 

What's the full call stack at the time of the crash?

0

Share this post


Link to post
Share on other sites

I'm going with Adam's guess. Sounds like some static object is destructing and crashing while doing so. I've had that a number of times with third-party libraries.

0

Share this post


Link to post
Share on other sites

Thought I'd add this post in case anyone comes across this thread in the future.  I didn't solve my problem as such but I do have more info on it, I just decided I'd go another way with my design as I didn't want to devote any more time to tracking this down.

 

As I said, the problem started when I ported my project to VS2010 Express.  I had done all previous coding with Code::Blocks and the exact code that produced the crash did not do so in Code::Blocks.

 

Linking the SFML libraries statically also solved the problem.  It's more a workaround than a solution, but that could help pinpoint it if one were so inclined.

 

In searching for a solution, I came across a few mentions of a crash on exit also related to sf::font in the SFML forums.  It apparently involved, as Adam and Sym surmised, a problem with the destruction order of certain items.  This did not lead to a solution though, and I want to be clear and say that I don't know nearly enough about SFML or C++ in general to say if my error was the same as the one I'm citing.  It's still entirely possible I was just messing something up on my end (I'd even say it's likely).

 

Anyway, like I said, this info is here for whatever use it can be if anyone in the future comes across this post.  Maybe it'll help, maybe it won't, but its here.

 

:)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0