Re: Crash in wrapper_base.cpp
Nigel Atkinson <[email protected]> Mon, 11 Jul 2011 13:21:07 +1000
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <1310354467.1527.24.camel@virNatty> |
Not sure about why you didn't get a Lua stack overflow - where you
popping the extra off? Perhaps luabind does.
Are you still getting the "wrong" objects disappearing in your game - I
forgot about that bit.
Thinking about how wrap_base works, I think it holds a weak reference to
the object, so perhaps thats why it appears "nil" immediately after you
do something like "obj = nil". That rules out using the finaliser or
destructor (as I'm doing) for unregistering the object in C++ land,
unless you make sure to collect garbage before calling any object
methods. However collecting garbage didn't work for my game for some
reason that I'll have to get to the bottom of.
> First, in my engine, if I simply add the following push of self onto
> the stack before calling the lua function then no crash!
>
> lua_State *L = m_self.state();
> m_self.get(L);
> call<void>("overide");
That is strange - I'm pretty sure the call function calls m_self.get(L)
internally - so somehow having two on the stack makes things work? What
is the value of whatever got pushed onto the Lua stack? nil sometimes?
> I find it weird that it didn't cause a stack overflow but I tried it
> many times and let it run for a long time with no observed side
> effects other than it seeming to be working correctly.
>
> The second observation is that when I put the extra push of self onto
> the stack into your sample code before calling overide() it caused an
> assert. After digging around I saw that you didn't provide a
> constructor for your lua class. Adding that in made the assert go
> away and also got rid of the "Lua instance is nil" messages.
>
> "function Item:__init(i)\n"
> " print('lua constructor')\n"
> "end\n"
That is weird - there is a C++ constructor bound. And why is it
constructing objects anyway!?
> So it seems we may have stumbled upon a workaround if it deems to have
> no side effects although I'm not really comfortable with not knowing
> why it works. Let me know what you find with your engine.
>
> Drew
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2