Crashes with QuickGui

SomeFusion

23-11-2007 12:43:11

Hi,

I'm experiencing crashes with QuickGui. My problem is whenever I try to
set a eventhandler to one of my Buttons I'm getting an error message I can't trace down.
This is how I set the callback:


mLoadButton->addEventHandler(QuickGUI::Widget::EVENT_MOUSE_BUTTON_UP, &EditorState::onLoadButtonClick, this);


My function is defined like this:

void onLoadButtonClick(const QuickGUI::EventArgs& args);



Now the error message I get is this:


The message basicaly says that I may have a corrupted heap wich may be caused by my executable or one of the DLLs.
I'm using Visual Studio 2005 SP1 on Vista. I have tried to recompile QuickGui but it didn't help.

Zini

23-11-2007 12:51:38

Could be anything. Impossible to say without more information (though the first thing to check would be, if mLoadButton was initialized properly).

kungfoomasta

23-11-2007 20:05:47

Break in and post the call stack, it might help. Like Zini says, we need more information.

SomeFusion

23-11-2007 20:50:42

Ah sorry I was going to post the callstack but I was in hurry when I postet here and forgot it, sorry.

ntdll.dll!77082ea8()
[Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für ntdll.dll]
ntdll.dll!770f0c9a()
ntdll.dll!770c4bdf()
ntdll.dll!7705894a()
> BombaChomba.exe!std::_Destroy_range<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >(QuickGUI::MemberFunctionSlot * * _First=0x014ad310, QuickGUI::MemberFunctionSlot * * _Last=0x0012f290, std::allocator<QuickGUI::MemberFunctionSlot *> & _Al={...}) Zeile 226 + 0x2e Bytes C++
BombaChomba.exe!std::allocator<QuickGUI::MemberFunctionSlot *>::deallocate(QuickGUI::MemberFunctionSlot * * _Ptr=0x014ad310, unsigned int __formal=1) Zeile 141 + 0x9 Bytes C++
BombaChomba.exe!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::_Insert_n(std::_Vector_iterator<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> > _Where=0xfdfdfdfd, unsigned int _Count=2, QuickGUI::MemberFunctionSlot * const & _Val=0x01515ef8) Zeile 1160 C++
BombaChomba.exe!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::insert(std::_Vector_iterator<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> > _Where=0xfdfdfdfd, QuickGUI::MemberFunctionSlot * const & _Val=0x01515ef8) Zeile 855 C++
BombaChomba.exe!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::push_back(QuickGUI::MemberFunctionSlot * const & _Val=0x01515ef8) Zeile 800 + 0x2d Bytes C++
BombaChomba.exe!QuickGUI::Widget::addEventHandler<EditorState>(QuickGUI::Widget::Event EVENT=EVENT_MOUSE_BUTTON_UP, void (const QuickGUI::EventArgs &)* function=0x004809cd, EditorState * obj=0x01513c58) Zeile 159 C++
BombaChomba.exe!EditorState::enter() Zeile 111 C++
BombaChomba.exe!GameManager::pushState(GameState * state=0x01513c58) Zeile 266 + 0x28 Bytes C++
BombaChomba.exe!GameManager::start(GameState * state=0x01513c58) Zeile 213 C++
BombaChomba.exe!main() Zeile 44 C++
BombaChomba.exe!__tmainCRTStartup() Zeile 327 + 0x19 Bytes C
BombaChomba.exe!mainCRTStartup() Zeile 196 C


This is the complete call stack in Debug mode. The strange thing is when I start my app in Release mode I see references to QuickGui.dll wich I don' have in Debug mode.

ntdll.dll!77082ea8()
[Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für ntdll.dll]
ntdll.dll!770f0c9a()
ntdll.dll!770c4bdf()
ntdll.dll!770f1cfa()
ntdll.dll!770bd9fa()
ntdll.dll!770a2447()
QuickGUI.dll!001b2d4a()
QuickGUI.dll!001b2bad()
QuickGUI.dll!0019712b()
ntdll.dll!770a2447()
ntdll.dll!770a214c()
ntdll.dll!770a1c21()
kernel32.dll!75ee7a7e()
> BombaChomba.exe!free(void * pBlock=0x0b5ce740) Zeile 110 C
BombaChomba.exe!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::_Insert_n(std::_Vector_iterator<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> > _Where=0xabababab, unsigned int _Count=1, QuickGUI::MemberFunctionSlot * const & _Val=0x00445560) Zeile 1156 + 0x6 Bytes C++
BombaChomba.exe!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::insert(std::_Vector_iterator<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> > _Where=0xabababab, QuickGUI::MemberFunctionSlot * const & _Val=0x00224ee0) Zeile 855 C++
BombaChomba.exe!EditorState::enter() Zeile 111 C++
BombaChomba.exe!GameManager::pushState(GameState * state=0x00221c38) Zeile 266 + 0x3d Bytes C++
BombaChomba.exe!GameManager::start(GameState * state=0x00221c38) Zeile 213 C++
BombaChomba.exe!main() Zeile 44 C++
BombaChomba.exe!__tmainCRTStartup() Zeile 327 + 0x12 Bytes C


When I comment out the lines where I register the handlers everything works very well, without any crashes. So its propably how I define my handlers (below) or maybe I use QuickGui in a wrong way. But I have looked through the QuickGui Ogre Demo but didn't notice any differences to the way I do it in my code.

void onLoadButtonClick(const QuickGUI::EventArgs& args); // in header

void EditorState::onLoadButtonClick( const QuickGUI::EventArgs& args )
{

std::cout << "load" << std::endl;
}


When I step into the function it seems to crash when he tries to insert the value into the vector.

What I noticed is that the iterator where it should be inserted is this:




- _Where 0xabababab std::_Vector_iterator<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >
- ptr 0xabababab QuickGUI::MemberFunctionSlot *
__vfptr CXX0030: Fehler: Ausdruck kann nicht ausgewertet werden



This is how the iterator looks when expanded in the auto watch window in visual studio.

Zini

23-11-2007 21:07:42

This has nothing to do with the event handler at all. My guess is, that you trashed your heap in a another part of your program or use an uninitialized pointer.


- _Where 0xabababab std::_Vector_iterator<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >
- ptr 0xabababab QuickGUI::MemberFunctionSlot *


actually looks pretty suspicious. I don't know MSVC well enough, but 0xabababab might be an indicator for some uninitialized variable. You need to show us some of your code, especially the part, where you are creating/initializing your stuff (mLoadButton, the relevant object of the class, which contains mLoadButton an so on).

kungfoomasta

23-11-2007 21:21:21

Some of the addresses do look suspicious, like "_Where=0xfdfdfdfd" statements.

When I step into the function it seems to crash when he tries to insert the value into the vector.

Are you referring to this function, or can you post the line the crashes when executed?


template<typename T> void addEventHandler(Event EVENT, void (T::*function)(const EventArgs&), T* obj)
{
mUserEventHandlers[EVENT].push_back(new MemberFunctionPointer<T>(function,obj));
}


Is this the only handler you've defined?


BombaChomba.exe!std::vector<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> >::insert(std::_Vector_iterator<QuickGUI::MemberFunctionSlot *,std::allocator<QuickGUI::MemberFunctionSlot *> > _Where=0xfdfdfdfd, QuickGUI::MemberFunctionSlot * const & _Val=0x01515ef8) Zeile 855 C++


Call stack is saying that the push_back function is failing, the end() iterator has address of 0xfdfdfdfd. I don't think this problem is directly related to QuickGUI, I would also think there is some kind of corruption going on. :?

Hopefully posting more code, like your EditorState::enter function, as well as initialization of QuickGUI, will help in solving the issue..

SomeFusion

23-11-2007 21:55:41

Hmm ok its not relatet to QuickGui. I use a std::vector somewhere else in my app and I'm getting the same error there.
I'll post a rundown what happens. In my EditorState (get the source here) when I press CTRL + S a xml file gets saved to the disk.
It calls GameWorld::saveLayoutToXml(Ogre::string path). This function works fine till the end.
I mean everything inbetween the brackets dosn't create any errors. But when
the function is "finalized" (I don't how what to call it) it seems to crash to some TinyXML related things.
But as soon as I leave the function ans TinyXML stuff gets destroyed my app crashes.

Btw, _Where is the iterator wich is in use when the crash happens.

Zini

23-11-2007 22:12:56

OK, once more. The error is not directly related to the place, where the crash happens. Even this iterator has probably nothing to do with it. You need to look further up. Assuming you have not trashed your heap completely, you need to check if the vector is constructed correctly (which probably means checking if the object, which contains the vector is constructed correctly) Without some code there is really nothing we can do to help you.

SomeFusion

24-11-2007 15:16:26

Ah sorry, maybe the link to the sources is a bit easy to everread :)
http://www.malwasandres.de/src.zip

Anyway I've updated the source with some more files wich I think they could help.

What could cause such a heap corruption? I'm a bit lost because no C++ book I've ever read dealt with such a case.

kungfoomasta

27-11-2007 18:43:29

SomeFusion, I haven't gotten around to looking at your code, but this may help:

http://www.ogre3d.org/wiki/index.php/Heap_Corruption