std::bad_alloc with mingw under windows 7

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Andreas
Posts: 166
Joined: Sun Oct 31, 2004 7:15 am
Location: Münster / Germany
Contact:

std::bad_alloc with mingw under windows 7

Post by Andreas »

Hi all,

currently i can't debug my game with (mingw) gdb under windows7 because i always get the following error:
 
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
The strange thing is, this is only when debugging the game with gdb. When i run the game normally, everything works.

Strangely it worked before. I suspect some windows update and already re-compiled irrlicht, but it didn't help.

Since i'm completely out of ideas, any help, hint or comment how to solve this would be highly appreciated! :)

Best regads
Andreas
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: std::bad_alloc with mingw under windows 7

Post by CuteAlien »

Do you get that right from the start? Or can you start debugging and this happens after a while? When things are that crazy I usually start to comment out code in my application until only the crash is left (divide and conquer debugging technique). Which can take a while in larger applications (took me once 3 days until I had reduced it to a test-case for gdb which those guys fixed then...).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Andreas
Posts: 166
Joined: Sun Oct 31, 2004 7:15 am
Location: Münster / Germany
Contact:

Re: std::bad_alloc with mingw under windows 7

Post by Andreas »

I can start debugging and even do the first move in the game, but then the following code from irrAllocator.h throws the exception:

Code: Select all

 
virtual void* internal_new(size_t cnt)
    {
        return operator new(cnt);
    }
 
The code is called from my game:

Code: Select all

 
map<EPLAYER_ID, array<SUnit> >::Node *node = units.find(playerId);
    if (node) {
        array<SUnit> units = node->getValue(); // <<<----- causing the problem
        ...
   }
 
But i can't image what the problem could be, because as i said, during normal execution the program runs fine. :cry:
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: std::bad_alloc with mingw under windows 7

Post by CuteAlien »

I also can't tell from that code alone. Well, divide and conquer really helps in such cases - you remove everything until you only have the crashing code left. It often clears things up. Or at least makes good test-cases which you can pass around then.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Andreas
Posts: 166
Joined: Sun Oct 31, 2004 7:15 am
Location: Münster / Germany
Contact:

Re: std::bad_alloc with mingw under windows 7

Post by Andreas »

OK, i will try to gather more information about the problem. Maybe i can isolate it, as you said, and find a solution.

Thanks for the very fast help! :)

Andreas
Post Reply