Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:35:05+00:00 2026-05-30T01:35:05+00:00

I am currently having problems using Luabind to interface a Lua scripted AI with

  • 0

I am currently having problems using Luabind to interface a Lua scripted AI with a C++ game.

I call an update function inside a loop (once per frame) and this function retrieves informations from C++ functions registered in Luabind.

My problem is as follows :
After a variable, non predictible time, there is an assertion failure in Luabind wich causes an abort.
The error always occurs into /usr/include/luabind/wrapper_base.hpp:124 while descending inside
the Lua.

Do you have any idea on what can do that ?
For my tests, the called functions in C++ and in LUA are always the same.

More details about the problem :

The content arround the assertion that failed in wrapper_base.hpp

typedef typename boost::mpl::if_<boost::is_void<R>, luabind::detail::proxy_member_void_caller<boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> >
, luabind::detail::proxy_member_caller<R, boost::tuples::tuple<BOOST_PP_ENUM(BOOST_PP_ITERATION(), LUABIND_TUPLE_PARAMS, _)> > >::type proxy_type;

// Comments removed

lua_State* L = m_self.state();
m_self.get(L);
assert(!lua_isnil(L, -1));
detail::do_call_member_selection(L, name);

if (lua_isnil(L, -1))
  {
    lua_pop(L, 1);
    throw std::runtime_error("Attempt to call nonexistent function");
  }

// push the self reference as the first parameter
m_self.get(L);

// now the function and self objects
// are on the stack. These will both
// be popped by pcall
return proxy_type(L, args);

The exact error

bomberman: /usr/include/luabind/wrapper_base.hpp:124: typename boost::mpl::if_<boost::is_void<T>, luabind::detail::proxy_member_void_caller<boost::tuples::tuple<boost::tuples::null_type,       boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >, luabind::detail::proxy_member_caller<R, boost::tuples::tuple<boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >::type luabind::wrap_base::call(const char*, luabind::detail::type_<Derived>*) const [with R = void]:
Assertion `!(lua_type(L, (-1)) == 0)' failed.
Aborted (core dumped)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:35:07+00:00Added an answer on May 30, 2026 at 1:35 am

    I had this problem a few days ago. In my particular case, the implicitly created Lua table that held all the methods that had been overridden in Lua for each object was being garbage collected, while the underlying C++ object was not. Because of this, if you tried to call a Lua member function from a C++ object, it would fail.

    The solution in my case was to keep a reference to the lua table alive as long as the C++ instance was alive. That was as simple as adding a luabind::object field to the C++ class and then setting it when you instantiate the class and it will be destroyed when the C++ class’s destructor is called, so in most cases you won’t have to worry about memory leaks. My code looks something like this now:

    class LuaC : public BaseC, public luabind::wrap_base {
        private:
            luabind::object _self; //retain a reference to the Lua part of this object so it doesn't get gc'd
        public:
            void setSelf(luabind::object nSelf) { _self=nSelf; }
    };
    //expose LuaC including the method setSelf
    // ...
    

    (BaseC is the C++ class you’re wrapping)

    Then from Lua, whenever you instantiate an instance of LuaC, call setSelf and pass self as an additional argument

    c = LuaC()
    c:setSelf(self)
    

    I would be surprised if there isn’t a way to simplify this and put it all inside the LuaC constructor so that it’s less error-prone (ie so you don’t have to worry about calling setSelf every time). But the documentation for LuaBind is rather shallow, so I couldn’t find any way to do this.

    Also, I believe the only way for this problem to occur is if you’re telling Luabind to only use references like shared_ptrs, because then the Lua part get’s garbage collected, along with the shared_ptr, but not necessarily the C++ instance referenced by the pointer. If Lua is managing the entire instance, then I don’t see how the Lua table could get deleted while the C++ instance lives on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently having problems calling a stored procedure async from within a insert-update-trigger.
I'm having problems passing utf-8 strings to javascript (ajax). Currently i'm using rawurlencode on
I'm making a simple game in Java using swing and am having problems with
I am currently having problems with attempting to style the HTML rich text editor
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
I am currently having some problems with <li> in IE6 essentially my code looks
Currently i am having some problems with getting some data out of a DataTable
I'm trying to build firefox but I'm having some problems. I currently have Visual
I'm currently having problems with the reintegrate branch option in cornerstone. I'm getting an
I'm having problems loading the parse_ini_file, currently I have registered a path in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.