Luabind shutdown crash with global pointer

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Luabind shutdown crash with global pointer

Dain Bray
 Hello I'm having an issue with luabind 0.9(using VS2010 RC -- had to fix various compiler errors to get it working though ) where if I register a class with luabind and then pass luabind a pointer to a C++ instance of that class -- luabind will crash on shutdown in object_rep.cpp calling this function...


    int destroy_instance(lua_State* L)
    {
        object_rep* instance = static_cast<object_rep*>(lua_touserdata(L, 1));

        lua_pushstring(L, "__finalize");
        lua_gettable(L, 1);                                  <--crashes on this line

        if (lua_isnil(L, -1))
        {
            lua_pop(L, 1);
        }
        else
        {
            lua_pushvalue(L, 1);
            lua_call(L, 1, 0);
        }

        instance->release_dependency_refs(L);
        instance->~object_rep();
        return 0;
    }


All I need to do to make it crash is something like this...(tried it with other classes too.. same results)

using namespace luabind;
luabind::module(_State)
[
luabind::class_<ILua>("ILua")
.def(constructor<const char*>())
];

luabind::globals(_State)["ILuaHandler"] = this;

If I take out the part where I assign the global value to the pointer it does not crash -- is luabind trying to take ownership of the pointer I am passing it? 

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Luabind shutdown crash with global pointer

Daniel Wallin
On Sun, Mar 14, 2010 at 07:04:12AM -0700, Dain Bray wrote:

>  Hello I'm having an issue with luabind 0.9(using VS2010 RC -- had to
> fix various compiler errors to get it working though ) where if I
> register a class with luabind and then pass luabind a pointer to a C++
> instance of that class -- luabind will crash on shutdown in
> object_rep.cpp calling this function...
>
>     int destroy_instance(lua_State* L)    {        object_rep* instance = static_cast<object_rep*>(lua_touserdata(L, 1));
>         lua_pushstring(L, "__finalize");        lua_gettable(L, 1);                                  <--crashes on this line
>         if (lua_isnil(L, -1))        {            lua_pop(L, 1);        }        else        {            lua_pushvalue(L, 1);            lua_call(L, 1, 0);        }
>         instance->release_dependency_refs(L);        instance->~object_rep();        return 0;    }
>
> All I need to do to make it crash is something like this...(tried it with other classes too.. same results)
> using namespace luabind; luabind::module(_State) [ luabind::class_<ILua>("ILua") .def(constructor<const char*>()) ];
> luabind::globals(_State)["ILuaHandler"] = this;
>
> If I take out the part where I assign the global value to the pointer
> it does not crash -- is luabind trying to take ownership of the
> pointer I am passing it? 

No, it doesn't take ownership. I can't tell what the problem is. Could
you possibly make this into a complete failing test?

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user