Assertion failure in inheritance.hpp

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

Assertion failure in inheritance.hpp

David Wolfe
[This is a resend of a message accidentally sent from the 'wrong' email
account. Sorry if the list winds up with two copies...]

When I run the program appended below on Windows (Visual Studio 8 2005),
I get the following:

Assertion failed: m_local_id >= local_id_base, file
C:\d\OdiGatewayEmulator\luab ind\luabind/detail/inheritance.hpp, line 86

But it seems to work fine on Linux/gcc 4.4.3.

Can anyone explain this? Moving the luabind::open() call inside Init()
(so that it doesn't get called at static initialization time) makes the
assertion go away, but I'd like to understand what's going on...

----------

#include <luabind/luabind.hpp>

struct Base
{
     virtual void DoIt() = 0;
};

struct Derived : Base
{
     lua_State* L;

     Derived()
     {
         L = luaL_newstate();
         luabind::open(L);
     }

     void Init()
     {
         using namespace luabind;
         module(L)
         [
             class_<Base>("Base"),
             class_<Derived, Base>("Derived")
               .def("DoIt", &Derived::DoIt)
         ];

         // This call triggers an assertion failure if *this is static
         globals(L)["thing"] = this;
     }

     void DoIt() { }
};


static Derived thing1;

int main()
{
     thing1.Init();  // <-- This call triggers an assertion failure
     Derived thing2;
     thing2.Init();  // <-- This call is okay
     return 0;
}

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Assertion failure in inheritance.hpp

Nigel Atkinson-2
Just of the top of my head, what is the value of L after the newstate
call in the static version?  Perhaps the Lua call is failing for some
reason?  Something to rule out at any rate.

Nigel

On Sat, 2010-10-09 at 14:39 -0400, David Wolfe wrote:

> [This is a resend of a message accidentally sent from the 'wrong' email
> account. Sorry if the list winds up with two copies...]
>
> When I run the program appended below on Windows (Visual Studio 8 2005),
> I get the following:
>
> Assertion failed: m_local_id >= local_id_base, file
> C:\d\OdiGatewayEmulator\luab ind\luabind/detail/inheritance.hpp, line 86
>
> But it seems to work fine on Linux/gcc 4.4.3.
>
> Can anyone explain this? Moving the luabind::open() call inside Init()
> (so that it doesn't get called at static initialization time) makes the
> assertion go away, but I'd like to understand what's going on...
>
> ----------
>
> #include <luabind/luabind.hpp>
>
> struct Base
> {
>      virtual void DoIt() = 0;
> };
>
> struct Derived : Base
> {
>      lua_State* L;
>
>      Derived()
>      {
>          L = luaL_newstate();
>          luabind::open(L);
>      }
>
>      void Init()
>      {
>          using namespace luabind;
>          module(L)
>          [
>              class_<Base>("Base"),
>              class_<Derived, Base>("Derived")
>                .def("DoIt", &Derived::DoIt)
>          ];
>
>          // This call triggers an assertion failure if *this is static
>          globals(L)["thing"] = this;
>      }
>
>      void DoIt() { }
> };
>
>
> static Derived thing1;
>
> int main()
> {
>      thing1.Init();  // <-- This call triggers an assertion failure
>      Derived thing2;
>      thing2.Init();  // <-- This call is okay
>      return 0;
> }
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Assertion failure in inheritance.hpp

David Wolfe
> Just of the top of my head, what is the value of L after the newstate
> call in the static version?

Right---good idea to rule out the obvious first. The debugger says this
for the static case:

   L = 0x015926b0

and this for an instance created on the stack:

   L = 0x002d26b0

Both seem reasonable, and other interpreter functions [e.g.,
luaL_dostring()] work fine...

On 10/9/2010 11:21 PM, Nigel Atkinson wrote:

> Just of the top of my head, what is the value of L after the newstate
> call in the static version?  Perhaps the Lua call is failing for some
> reason?  Something to rule out at any rate.
>
> Nigel
>
> On Sat, 2010-10-09 at 14:39 -0400, David Wolfe wrote:
>> [This is a resend of a message accidentally sent from the 'wrong' email
>> account. Sorry if the list winds up with two copies...]
>>
>> When I run the program appended below on Windows (Visual Studio 8 2005),
>> I get the following:
>>
>> Assertion failed: m_local_id>= local_id_base, file
>> C:\d\OdiGatewayEmulator\luab ind\luabind/detail/inheritance.hpp, line 86
>>
>> But it seems to work fine on Linux/gcc 4.4.3.
>>
>> Can anyone explain this? Moving the luabind::open() call inside Init()
>> (so that it doesn't get called at static initialization time) makes the
>> assertion go away, but I'd like to understand what's going on...
>>
>> ----------
>>
>> #include<luabind/luabind.hpp>
>>
>> struct Base
>> {
>>       virtual void DoIt() = 0;
>> };
>>
>> struct Derived : Base
>> {
>>       lua_State* L;
>>
>>       Derived()
>>       {
>>           L = luaL_newstate();
>>           luabind::open(L);
>>       }
>>
>>       void Init()
>>       {
>>           using namespace luabind;
>>           module(L)
>>           [
>>               class_<Base>("Base"),
>>               class_<Derived, Base>("Derived")
>>                 .def("DoIt",&Derived::DoIt)
>>           ];
>>
>>           // This call triggers an assertion failure if *this is static
>>           globals(L)["thing"] = this;
>>       }
>>
>>       void DoIt() { }
>> };
>>
>>
>> static Derived thing1;
>>
>> int main()
>> {
>>       thing1.Init();  //<-- This call triggers an assertion failure
>>       Derived thing2;
>>       thing2.Init();  //<-- This call is okay
>>       return 0;
>> }
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2&  L3.
>> Spend less time writing and  rewriting code and more time creating great
>> experiences on the web. Be a part of the beta today.
>> http://p.sf.net/sfu/beautyoftheweb
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2&  L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user