I just checked in a fix for what may be a similar error. The
On Jan 3, 2008 9:35 AM, Klaas Holwerda <[EMAIL PROTECTED]> wrote:
> Hi John,
>
> I did all you suggested, but the problem is, it does not fail where you expect
> it. This does not mean that the error is not created where you think.
>
> With this here added as you suggested, the output is as i expected.
>
> wxLogDebug(wxT("pushuserdatatype1 %p %p pushing %p type %d\n"),
> a2dLuaWP, a2dMaskProc, obj_ptr, wxl_type);
>
> if (wxluaO_istrackedweakobject(L, (void*)obj_ptr, wxl_type, true))
> return true;
>
> wxLogDebug(wxT("pushuserdatatype2 %p %p pushing %p type %d\n"),
> a2dLuaWP, a2dMaskProc, obj_ptr, wxl_type);
>
> ========= OUTPUT ===============
>
> 14:43:47: pushuserdatatype1 020062B0 020062B0 pushing 020062B0 type 426
>
> 14:43:47: pushuserdatatype2 020062B0 020062B0 pushing 020062B0 type 426
>
> 14:44:21: pushuserdatatype1 020062B0 020062B0 pushing 020062B0 type 429
>
> 14:44:21: pushuserdatatype2 020062B0 020062B0 pushing 020062B0 type 429
>
> First-chance exception in maskproc.exe: 0xC0000005: Access Violation.
> First-chance exception in maskproc.exe (KERNEL32.DLL): 0xE06D7363: Microsoft
> C++
> Exception.
>
> Here the second time the same pointer is pushed, i get the exception with the
> stack dump at the end of this mail. From the output it is clear I do not have
> a
> tracked object/pointer, because in both cases false is returned.
It is normal that it can't find the object when you're registering the
bindings since it's being push for the first time. The whole idea
behind the check for wxluaO_istrackedweakobject() is that we don't
want to create multiple Lua userdata wrapping our C++ object, but push
the same one again. However, just like in C++ the object can be cast
to different types and wxLua must create new userdata for each type to
distinguish them (for wxObject::DynamicCast()).
> Now the second time the same pointer is pushed, it follows a different path in
> this function here, but in both cases the return is false. But the first time
> it skips the "if (lua_istable(L, -1))" part, while the second it goes in
> there,
> but the "if (wxlua_iswxuserdata(L, -1) && (wxl_type == wxluaT_type(L,
> -1)))"part
> is skipped.
Exactly, the second time through it finds that the object was already
pushed, but with a different type so as far as wxLua is concerned,
it's not what we want and returns false.
> ===============Stack ================
>
> luaO_rawequalObj(const lua_TValue * 0x4d6584b1, const lua_TValue * 0x02006608)
> line 73 + 6 bytes
> luaH_get(Table * 0x02174b60, const lua_TValue * 0x02006608) line 484 + 16
> bytes
> luaH_set(lua_State * 0x02006318, Table * 0x02174b60, const lua_TValue *
> 0x02006608) line 495 + 13 bytes
> lua_rawset(lua_State * 0x02006318, int -3) line 673 + 37 bytes
??? What happens here?
wxLuaBinding::DoRegisterBinding
...
if (wxlObject->objPtr != 0)
wxluaT_pushuserdatatype(L, wxlObject->objPtr,
*wxlObject->wxluatype, true);
then
bool LUACALL wxluaT_pushuserdatatype
...
if (wxluaR_getref(L, wxl_type, &wxlua_lreg_types_key))
{
// pop the table and set it as the metatable for the newuserdata
lua_setmetatable(L, -2);
if (track)
wxluaO_trackweakobject(L, -1, (void*)obj_ptr, wxl_type);
return true; // leave value on the stack
}
Does it crash in wxluaO_trackweakobject() or wxluaR_getref()?
> wxLuaBinding::DoRegisterBinding(const wxLuaState & {...}, int 1) line 1191 +
> 11
> bytes
> wxLuaBinding::RegisterBinding(const wxLuaState & {...}) line 985
> wxLuaState::RegisterBindings() line 2687 + 17 bytes
> wxLuaState::Create(lua_State * 0x02006318, int 2) line 2221
Thanks,
John
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users