Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding (Assertion `!lua_isnil(L->L, -1)' failed) #516

Open
cinterloper opened this issue Nov 21, 2021 · 1 comment
Open

Embedding (Assertion `!lua_isnil(L->L, -1)' failed) #516

cinterloper opened this issue Nov 21, 2021 · 1 comment

Comments

@cinterloper
Copy link
Contributor

cinterloper commented Nov 21, 2021

I have some code that embeds terra in a c program, it was written several years ago and worked at the time.

With the current release of terra, when I try to terra_loadbuffer or terra_loadstring or terra_dostring, the program bails out with the message:

terra/src/llex.cpp:94: void luaX_pushtstringtable(terra_State*): Assertion `!lua_isnil(L->L, -1)' failed.

Is there a new canonical example of how to embed Terra in a c/c++ program?

An example of this failing would be:

    lua_State *lua_state = luaL_newstate();
    if (lua_state == nullptr){
        cout << "cannot init lua state" << endl;
        return 5;
    }
    luaL_openlibs(lua_state);
    terra_init(lua_state);
    terra_loadstring(lua_state,R"(print("Hello, Lua!") )");

where the program crashes at the terra_loadstring call

@elliottslaughter
Copy link
Member

Is it possible you changed what LuaJIT you were building against? I don't think this interface has changed, as far as I'm aware.

The couple of examples I'm seeing in the test suite are similar to what you're doing:

https://github.com/terralang/terra/blob/cff49cb29654c88e5d1ea3484e22bc77a80e58e2/tests/multiterra.t

https://github.com/terralang/terra/blob/cff49cb29654c88e5d1ea3484e22bc77a80e58e2/tests/dynlib.t

The error handling in the latter example suggests maybe you're missing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants