From: klaas.holwerda <kho...@xs...> - 2005-12-25 16:01:55
|
Hi John, I hope you have some ideas which i can still check. After many hours, i still have no idea where to look. I can compile and link the lua libraries + my own wrappings, but as soon as i add the next two members to any app, and run that app (doing really nothing with lua ), i get the crash with stack down here. This is during m_classinfo static member initialization for IMPLEMENT_DYNAMIC_CLASS. It is always the same problm, but if i do the same in any another app, i get it it the first class initialized all the time. Without the WxLuaState added, it work fine. I did check if i only link the need lua libs ones only, and it seems so from the list i see. I saw some time a ago (when you were working on wxLua ), when compiling/linking you had an overview in the output window of linked libraries, how did you make that setting? Maybe that will tell me more. I really don't have a clue what is going on. Any ideas welcome! Klaas class MyApp: public wxApp { public: MyApp(); virtual bool OnInit(); virtual int OnExit(); MyFrame *m_frame; wxLuaState m_wxlState; lua_State *m_luaState; }; NTDLL! 77f7f570() NTDLL! 77f67dc6() KERNEL32! 77e6c936() _CrtIsValidHeapPointer(const void * 0x00322bf0) line 1697 _free_dbg_lk(void * 0x00322bf0, int 1) line 1044 + 9 bytes _free_dbg(void * 0x00322bf0, int 1) line 1001 + 13 bytes free(void * 0x00322bf0) line 956 + 11 bytes wxListKey::~wxListKey() line 379 + 15 bytes wxListBase::Append(const char * 0x00d166fc, void * 0x00e1be50 class wxClassInfo wxEvtHandler::ms_classInfo) line 273 wxObjectList::Append(const char * 0x00d166fc, void * 0x00e1be50 class wxClassInfo wxEvtHandler::ms_classInfo) line 1122 + 30 bytes wxHashTable::Put(const char * 0x00d166fc, wxObject * 0x00e1be50 class wxClassInfo wxEvtHandler::ms_classInfo) line 485 wxClassInfo::Register() line 245 wxClassInfo::wxClassInfo(const char * 0x00d166fc, const wxClassInfo * 0x00e1be80 class wxClassInfo wxObject::ms_classInfo, const wxClassInfo * 0x00000000, int 40, wxObject * (void)* 0x00408242 wxEvtHandler::wxCreateObject(void)) line 77 $E31() line 66 + 32 bytes $E35() + 8 bytes _initterm(void (void)* * 0x00d14114 $S36, void (void)* * 0x00d1600c ___xc_z) line 525 WinMainCRTStartup() line 274 + 15 bytes KERNEL32! 77e7eb69() |
From: John L. <jla...@gm...> - 2005-12-25 18:13:10
|
> I can compile and link the lua libraries + my own wrappings, but as soon > as i add the next two members to any app, and run that app (doing > really nothing with lua ), i get the crash with stack down here. > This is during m_classinfo static member initialization for > IMPLEMENT_DYNAMIC_CLASS. > It is always the same problm, but if i do the same in any another app, i > get it it the first class initialized all the time. Without the > WxLuaState added, it work fine. Humm, what compiler, version of wxWidgets? > I did check if i only link the need lua libs ones only, and it seems so > from the list i see. > I saw some time a ago (when you were working on wxLua ), when > compiling/linking you had an overview in the output window of linked > libraries, how did you make that setting? Maybe that will tell me more. I haven't seen this using VC6 or in gcc. I did have some problems with VC 2003, the free command line one, but I thought it was an oddity. > class MyApp: public wxApp > { > public: > MyApp(); > > virtual bool OnInit(); > virtual int OnExit(); > > MyFrame *m_frame; > wxLuaState m_wxlState; > lua_State *m_luaState; > }; You should access the lua_State through the m_wxlState.GetLuaState(). The app wxLua still has the lua_State as a member as a throwback to the old way and will be removed when I get a chance. The whole idea of using the wxLuaState is that you won't have problems of destroying the pointer to the lua_State and then trying to access it later. > NTDLL! 77f7f570() > NTDLL! 77f67dc6() > KERNEL32! 77e6c936() > _CrtIsValidHeapPointer(const void * 0x00322bf0) line 1697 > _free_dbg_lk(void * 0x00322bf0, int 1) line 1044 + 9 bytes > _free_dbg(void * 0x00322bf0, int 1) line 1001 + 13 bytes > free(void * 0x00322bf0) line 956 + 11 bytes > wxListKey::~wxListKey() line 379 + 15 bytes > wxListBase::Append(const char * 0x00d166fc, void * 0x00e1be50 class What is this string? It should be the name of the class it's trying to add. I have no idea why this should happen. I guess the stack is getting messed up by some earlier static initialization and carrying through. This will be tough to track through, We can look at the linking order of the object files to follow them backwards to see what is being initialized before this code is run. > wxClassInfo wxEvtHandler::ms_classInfo) line 273 > wxObjectList::Append(const char * 0x00d166fc, void * 0x00e1be50 class > wxClassInfo wxEvtHandler::ms_classInfo) line 1122 + 30 bytes > wxHashTable::Put(const char * 0x00d166fc, wxObject * 0x00e1be50 class > wxClassInfo wxEvtHandler::ms_classInfo) line 485 > wxClassInfo::Register() line 245 > wxClassInfo::wxClassInfo(const char * 0x00d166fc, const wxClassInfo * > 0x00e1be80 class wxClassInfo wxObject::ms_classInfo, const wxClassInfo * > 0x00000000, int 40, wxObject * (void)* 0x00408242 > wxEvtHandler::wxCreateObject(void)) line 77 > $E31() line 66 + 32 bytes > $E35() + 8 bytes > _initterm(void (void)* * 0x00d14114 $S36, void (void)* * 0x00d1600c > ___xc_z) line 525 > WinMainCRTStartup() line 274 + 15 bytes > KERNEL32! 77e7eb69() Regards, John Labenski |
From: klaas.holwerda <kho...@xs...> - 2005-12-26 15:21:54
|
Hi, John Labenski wrote: >> >> > >Humm, what compiler, version of wxWidgets? > > Vc6.0 Sp5 wx2.6.2 >I haven't seen this using VC6 or in gcc. I did have some problems with >VC 2003, the free command line one, but I thought it was an oddity. > > If it was only my application, but wxLua seems to have the same problem here. Crash in same stack, with class name wxLuaDebugServer. Same wxLuaedit, but there it is wxLuaShell. This is using the VCproject files like in CVS. In wxArt2D i use Cmake generated project files, so this is no the problem ( linking order etc. ). > > >You should access the lua_State through the m_wxlState.GetLuaState(). >The app wxLua still has the lua_State as a member as a throwback to >the old way and will be removed when I get a chance. > Oke i see, was wondering already why ;-) I just a copy paster here, since i do not understand how everything works together. Once i can actually run something, i think things will become more clear to me. Still i very much hope you will find some time to make a state ot the art sample, to demo how it is done. Not that i what to be pushing ;-) > The whole idea of >using the wxLuaState is that you won't have problems of destroying the >pointer to the lua_State and then trying to access it later. > > Oke, i understand now. Although i don't get that reference counting mechanism. ( like brush and pens in wxWidgets right?) Is it possible that one wants to derive from wxLuaState? I wonder if plain smart pointers would have bin easier/better or not? Not that i know, but in wxArt2D i had problems deriving from wxBrush because of this. In any case, i hope my problems or not due to this. > >What is this string? It should be the name of the class it's trying to >add. > It is! But constantly some othere classname, depending upon the first on added in some app. > I have no idea why this should happen. I guess the stack is >getting messed up by some earlier static initialization and carrying >through. > I think too, and it is related to wxLuaState here :-( >This will be tough to track through, We can look at the >linking order of the object files to follow them backwards to see what >is being initialized before this code is run. > > How to do that? I will now try to test wxLua on Vc.Net, see if the problem is the same there. How is it possible i have this problem and you don't? The only warning i do get is the next, but this doe not harm i think. Linking... LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library wxluaedit.exe - 0 error(s), 1 warning(s) Regards, Klaas |
From: klaas.holwerda <kho...@xs...> - 2005-12-26 16:55:57
|
Hi John, ( still Vc6 and 2.6.2 and debug verson of builds) Some more findings. I did a complete new check out of wxLua, went to the build/msw dir. And did a build of app_wxlua in the wxLua.dsw. ( in principle a rebuild all i think ). Guess what, it works fine! Now i go to apps/build/msw and open apps.dsw. I set app_wxlua as active project, and its active configuaration to debug. And now i do a rebuild all on this project, and run wxLua from there. And now there is the same problem again. ( see stack dump of other mails ). For app_wxluaedit the outcome is the same. Now i go back to the first wxLua.dsw. If i run directly app_wxlua from in there the problem is the same, since no build is done. But now i do a change in console.cpp in order to force a build, and everything is oke again. If i go once more tp aps/build/msw/apps.dsw, and make in there a change to console.cpp, to force a build from there, the problem is there again. Can you reproduce this ? If we both have the same problem, we might be able to find what is causing it. Still trying to get things in order for VC.net, but that will take me a day, compiling everything wx etc. Regards, Klaas klaas.holwerda wrote: > Hi, > > John Labenski wrote: > |
From: klaas.holwerda <kho...@xs...> - 2005-12-26 17:21:06
|
A solution, Following is the contents of the settings dialog under tab Link. ( called project options. ) If i cut and paste the last one ( from wxLua.dsw ) into the one from apps.dsw/app_wxlua. And make a change to force a build, it works. Same trick for app_wxluaedit ( but of course add wxedit.lib too ), makes that one work. Even not forcing a rebuild, but just relink, gives the problem. Is it caused by?: /nodefaultlib:"MSVCRT.lib" Adding this options, and doing a rebuild of e.g. app_wxlua, makes it work. Removing it again, gives the problem again, so i think this is the solution. No back to wxArt2D to see if it is the same there ;-) And the option i was asking for is called /VERBOSE:LIB i think ;-) Klaas wxluasocket.lib wxluadebug.lib wxbind.lib wxlua.lib lua.lib wxmsw26d_stc.lib wxmsw26d_xrc.lib wxmsw26d_html.lib wxmsw26d_media.lib wxmsw26d_adv.lib wxbase26d_net.lib wxbase26d_xml.lib wxmsw26d_core.lib wxbase26d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib oleacc.lib /nologo /subsystem:windows /incremental:yes /pdb:"..\..\..\bin/wxlua.pdb" /debug /machine:I386 /out:"..\..\..\bin\wxlua.exe" /libpath:"$(WXWIN)\lib\vc_lib" /libpath:"..\..\..\lib\vc_lib" wxluadebug.lib wxluasocket.lib wxlua.lib wxbind.lib lua.lib wxmsw26d_stc.lib wxmsw26d_html.lib wxbase26d_net.lib wxmsw26d_xrc.lib wxmsw26d_adv.lib wxbase26d_xml.lib wxmsw26d_core.lib wxbase26d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib oleacc.lib /nologo /subsystem:windows /incremental:yes /pdb:"..\..\..\bin/wxlua.pdb" /debug /machine:I386 /nodefaultlib:"MSVCRT.lib" /out:"..\..\..\bin\wxlua.exe" /libpath:"$(WXWIN)\lib\vc_lib" /libpath:"..\..\..\lib\vc_lib" /VERBOSE:LIB klaas.holwerda wrote: > Hi John, > |
From: klaas.holwerda <kho...@xs...> - 2005-12-26 17:25:37
|
klaas.holwerda wrote: > > > No back to wxArt2D to see if it is the same there ;-) > just added the same switch, and now it is oke. Oef! Back to learning the internals of wxLua :-) Klaas |
From: John L. <jla...@gm...> - 2005-12-28 15:18:00
|
> > No back to wxArt2D to see if it is the same there ;-) > > > just added the same switch, and now it is oke. Thats good, I have no idea how to fix static initialization problems elegantly. I would have had use a brute force method that just rems out static code (and anything that depends on it) until it worked. > Back to learning the internals of wxLua :-) Let me know if you have any questions. -John |
From: klaas.holwerda <kho...@xs...> - 2005-12-28 21:13:59
|
Hi John, Do not forget to modify apps.dsw ( somewhere in bakefiles ) to add that option. And you are right about static initialization, trhis is a problem, having the following bindings: class wxart2d_BindingInit { public: wxart2d_BindingInit() { m_binding.GetBindingList()->Append(&m_binding); } wxart2d_Binding m_binding; }; wxart2d_BindingInit s_wxart2d_BindingInit; This last static instance is not called. ( it is inside a libary here ). If i move to my main program, it is called, but to early because the next wxLuaBindingList wxLuaBinding::sm_bindings is not yet initialized. First i don't understand why it is not called when it is part of my luawraps library. ( the library is linked, and i can a wxart2d_Binding dummy in my main, so it is there ). Next i don't know how to change the order of initialization of static objects. I will ask Michael now, maybe he knows a solution, Klaas John Labenski wrote: >>>No back to wxArt2D to see if it is the same there ;-) >>> >>> >>> >>just added the same switch, and now it is oke. >> >> > >Thats good, I have no idea how to fix static initialization problems >elegantly. I would have had use a brute force method that just rems >out static code (and anything that depends on it) until it worked. > > > |
From: John L. <jla...@gm...> - 2005-12-28 22:04:35
|
> Do not forget to modify apps.dsw ( somewhere in bakefiles ) to add that > option. Fixed (if I understand bakefile correctly), I'm recompiling it now and so far so good. > And you are right about static initialization, trhis is a problem, > having the following bindings: > > class wxart2d_BindingInit > { > public: > wxart2d_BindingInit() > { > m_binding.GetBindingList()->Append(&m_binding); > } > wxart2d_Binding m_binding; > }; > > wxart2d_BindingInit s_wxart2d_BindingInit; > > This last static instance is not called. ( it is inside a libary here ). > If i move to my main program, it is called, but to early because the next > wxLuaBindingList wxLuaBinding::sm_bindings is not yet initialized. Can you not do this at all, because it is in a library? I thought this would be a clever trick to ensure that all the bindings were initialized and made available at runtime. This way you do not have to know the name of anything and so we can even remove the dependence on the wxWidgets binding. What would be an alternative? One way would be to make the user add any bindings they want to a static member of wxLuaBinding themselves in the wxApp::OnInit. The only reason to have the static member is so that they don't have to always add the bindings everytime they create a new wxLuaState, but by default it will try to load the ones set to the static wxList of them. > First i don't understand why it is not called when it is part of my > luawraps library. > ( the library is linked, and i can a wxart2d_Binding dummy in my main, > so it is there ). > Next i don't know how to change the order of initialization of static > objects. I thought they are "run" in the order that they're linked. Or in the cases of some compilers, the reverse order that they appear on the linking command line. > I will ask Michael now, maybe he knows a solution, Hopefully. -John Labenski > John Labenski wrote: > > >>>No back to wxArt2D to see if it is the same there ;-) > >>> > >>> > >>> > >>just added the same switch, and now it is oke. > >> > >> > > > >Thats good, I have no idea how to fix static initialization problems > >elegantly. I would have had use a brute force method that just rems > >out static code (and anything that depends on it) until it worked. > > > > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > _______________________________________________ > Wxlua-users mailing list > Wxl...@li... > https://lists.sourceforge.net/lists/listinfo/wxlua-users > |
From: klaas.holwerda <kho...@xs...> - 2005-12-29 14:28:08
|
Hi John, First would you think it is possible to debug into lapi.c using VC IDE? As soon as i arrive in this code breakpoint do not work, and my program is stuck. I have my bindings added as below, but i can't get it to work. Meaning wxLuaState::RunFile() gets stuck in wxLuaState::LuaDoFile() at the lua_pcall statement. And i can not go into it. This is also the case in wxLua itself, i don't understand why. e.g. I have the next aaaa.lua file, the first statement works, it shows the message box. But for the rest nothing is done, the functions in my binding are not called. wx.wxMessageBox( 'This is the "About" dialog of the Scribble wxLua Sample.', "About wxLua", wx.wxOK + wx.wxICON_INFORMATION ) wx.a2dLuaWP:Message("blah blah") wx.a2dLuaWP:FileOpen("../drawings/polygons.cvg") How does one check if binding work somehow, or where and for what reason it is not done? Can you give me a handy breakpoint, to see what is going on? John Labenski wrote: >Can you not do this at all, because it is in a library? I thought this >would be a clever trick to ensure that all the bindings were >initialized and made available at runtime. This way you do not have to >know the name of anything and so we can even remove the dependence on >the wxWidgets binding. > > I understand it, and i think it should be possible. (it is already happening from the wxlua libs itself, so why not mine. But the order of initialization is a problem still, even if it would work. Depend on initialization order is a bit risky. I have here simular modules, and i use derived wxModule classes to make sure everything get properly initialized. Even there the order is not always clear, but for that i set a flag in lower order modules and call them in higher module initalizations , so in the end the order is fine. >What would be an alternative? > Maybe wxModule like initialization? >One way would be to make the user add >any bindings they want to a static member of wxLuaBinding themselves >in the wxApp::OnInit. > That is what i do now. I make the binding a static member of MyApp. class MyApp { static wxart2d_binding m_wxart2dluab; } wxart2d_binding MyApp::m_wxart2dluab; and in onInit() m_wxart2dluab.GetBindingList()->Append( &m_wxart2dlaub); >The only reason to have the static member is so >that they don't have to always add the bindings everytime they create >a new wxLuaState, but by default it will try to load the ones set to >the static wxList of them. > > I see in wxLuaStateRefDate that those static wxLuaBinding::GetBindingList() is added to the real/actual bindings of the wxLuaState. I assume that is what you are saying. Regards, Klaas > > > > > > |