Ticket #128 (closed defect: fixed)
Bad Subscript in Container::Search
| Reported by: | Dido | Owned by: | knowknowledge |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | UI | Version: | |
| Keywords: | Cc: |
Description
It comes out after hiting "Play". Expression "subscript out of range". Here`s the whole callstack:
> Epiar_debug.exe!std::_Debug_message(const wchar_t * message, const wchar_t * file, unsigned int line) Line 15 C++
Epiar_debug.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator[](unsigned int _Off) Line 1441 + 0x14 bytes C++
Epiar_debug.exe!Container::Search(std::basic_string<char,std::char_traits<char>,std::allocator<char> > full_query) Line 239 + 0xa bytes C++
Epiar_debug.exe!UI::Search(std::basic_string<char,std::char_traits<char>,std::allocator<char> > query) Line 103 + 0x1e bytes C++
Epiar_debug.exe!UI_Lua::search(lua_State * L) Line 464 + 0x19 bytes C++
0bb9076a()
Epiar_debug.exe!luaJIT_run(lua_State * L, lua_TValue * func, int nresults) Line 223 + 0x1c bytes C
Epiar_debug.exe!luaD_precall(lua_State * L, lua_TValue * func, int nresults) Line 281 + 0x11 bytes C
Epiar_debug.exe!luaD_call(lua_State * L, lua_TValue * func, int nResults) Line 383 + 0x11 bytes C
Epiar_debug.exe!f_call(lua_State * L, void * ud) Line 795 + 0x16 bytes C
Epiar_debug.exe!luaD_rawrunprotected(lua_State * L, void (lua_State *, void *)* f, void * ud) Line 119 + 0x1f bytes C
Epiar_debug.exe!luaD_pcall(lua_State * L, void (lua_State *, void *)* func, void * u, int old_top, int ef) Line 464 + 0x11 bytes C
Epiar_debug.exe!lua_pcall(lua_State * L, int nargs, int nresults, int errfunc) Line 816 + 0x20 bytes C
Epiar_debug.exe!Lua::Call(const char * func, const char * sig, ...) Line 131 + 0x15 bytes C++
Epiar_debug.exe!Simulation::Run() Line 187 + 0xf bytes C++
Epiar_debug.exe!Main_Menu() Line 555 C++
Epiar_debug.exe!SDL_main(int argc, char * * argv) Line 69 C++
Epiar_debug.exe!main(int argc, char * * argv) Line 315 + 0xd bytes C
Epiar_debug.exe!WinMain(HINSTANCE__ * hInst, HINSTANCE__ * hPrev, char * szCmdLine, int sw) Line 398 + 0xd bytes C
Epiar_debug.exe!__tmainCRTStartup() Line 275 + 0x2c bytes C
Epiar_debug.exe!WinMainCRTStartup() Line 189 C
kernel32.dll!7c817077()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
Ive tried debugging it but there are so much calls to search and Im not an expert on lua. To state it again, this came out on MSVC 2010 express.
(Bug caught by Dido. Ticket created by knowknowledge)
Change History
comment:2 Changed 2 years ago by knowknowledge
Expression: "list iterator is incompatible"
Callstack:
> Epiar_debug.exe!std::_Debug_message(const wchar_t * message, const wchar_t * file, unsigned int line) Line 15 C++
Epiar_debug.exe!std::_List_const_iterator<std::_List_val<Widget *,std::allocator<Widget *> > >::operator==(const std::_List_const_iterator<std::_List_val<Widget *,std::allocator<Widget *> > > & _Right) Line 286 + 0x14 bytes C++
Epiar_debug.exe!Container::Search(std::basic_string<char,std::char_traits<char>,std::allocator<char> > full_query) Line 325 + 0x3d bytes C++
Epiar_debug.exe!UI::Search(std::basic_string<char,std::char_traits<char>,std::allocator<char> > query) Line 103 + 0x1e bytes C++
Epiar_debug.exe!UI_Lua::search(lua_State * L) Line 505 + 0x19 bytes C++
0cb0076a()
Epiar_debug.exe!luaJIT_run(lua_State * L, lua_TValue * func, int nresults) Line 223 + 0x1c bytes C
Epiar_debug.exe!luaD_precall(lua_State * L, lua_TValue * func, int nresults) Line 281 + 0x11 bytes C
0cb00707()
Epiar_debug.exe!luaJIT_run(lua_State * L, lua_TValue * func, int nresults) Line 223 + 0x1c bytes C
Epiar_debug.exe!luaD_precall(lua_State * L, lua_TValue * func, int nresults) Line 281 + 0x11 bytes C
Epiar_debug.exe!luaD_call(lua_State * L, lua_TValue * func, int nResults) Line 383 + 0x11 bytes C
Epiar_debug.exe!f_call(lua_State * L, void * ud) Line 795 + 0x16 bytes C
Epiar_debug.exe!luaD_rawrunprotected(lua_State * L, void (lua_State *, void *)* f, void * ud) Line 119 + 0x1f bytes C
Epiar_debug.exe!luaD_pcall(lua_State * L, void (lua_State *, void *)* func, void * u, int old_top, int ef) Line 464 + 0x11 bytes C
Epiar_debug.exe!lua_pcall(lua_State * L, int nargs, int nresults, int errfunc) Line 816 + 0x20 bytes C
Epiar_debug.exe!Lua::Run(std::basic_string<char,std::char_traits<char>,std::allocator<char> > line, bool allowReturns) Line 71 + 0x2d bytes C++
Epiar_debug.exe!Button::Activate() Line 102 + 0x20 bytes C++
Epiar_debug.exe!Button::MouseLUp(int xi, int yi) Line 121 C++
Epiar_debug.exe!Container::MouseLUp(int xi, int yi) Line 596 + 0x1a bytes C++
Epiar_debug.exe!Container::MouseLUp(int xi, int yi) Line 596 + 0x1a bytes C++
Epiar_debug.exe!UI::HandleMouse(InputEvent i) Line 199 + 0x12 bytes C++
Epiar_debug.exe!UI::HandleInput(std::list<InputEvent,std::allocator<InputEvent> > & events) Line 156 + 0x34 bytes C++
Epiar_debug.exe!Simulation::HandleInput() Line 474 + 0x9 bytes C++
Epiar_debug.exe!Simulation::Run() Line 207 + 0x8 bytes C++
Epiar_debug.exe!Main_Menu() Line 555 C++
Epiar_debug.exe!SDL_main(int argc, char * * argv) Line 69 C++
Epiar_debug.exe!main(int argc, char * * argv) Line 315 + 0xd bytes C
Epiar_debug.exe!WinMain(HINSTANCE__ * hInst, HINSTANCE__ * hPrev, char * szCmdLine, int sw) Line 398 + 0xd bytes C
Epiar_debug.exe!__tmainCRTStartup() Line 275 + 0x2c bytes C
Epiar_debug.exe!WinMainCRTStartup() Line 189 C
kernel32.dll!7c817077()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
Traced to "if( i == current->children.end() )". I cant see the problem. Only found that this expression usualy means that an iterator is invalid after a container has been modified. I cant see how ".end()" or "i" woul be invalid.
-Dido
comment:3 Changed 2 years ago by knowknowledge
- Owner set to knowknowledge
- Status changed from new to accepted
The problem here wasn't that 'i' or '.end()' were invalid, but that the 'current' variable was changed and the iterator was not pointing to a member of the new current->children list.
I've pushed a fix.
This is a pretty bad mistake and I'm personally surprised that it ever worked in the first place.
Thanks for finding this.
If Search stops failing then I'll close this ticket.