[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: integration with C. Segfault whenever I do anything outside of my lua_state initializer function.
- From: Max <maxxedout@...>
- Date: Wed, 16 Sep 2009 07:55:10 -0700
Hi everyone! I originally posted this to the forum but I was told I'd be
more likely to get help here, so here I am.
I'm trying to modify an existing game engine by adding Lua support. This
is the first real Lua project I've ever done and I'm not exactly a C
expert either, but I'm pretty sure I've gone by the book here.
I started having problems with the Lua integration as soon as I moved
everything to its own file, so I took that file somewhere else and wrote
some simple code to test that file.
Here is the file, lua.c, which I was trying to add to the game engine
(with game-engine specific components commented out and replaced with OS
Here is the file which I wrote in order to test lua.c:
Here is the lua script I'm using:
Here is the command-line output of me compiling the program, running it,
and a gdb session as well.
Essentially, I've got two major functions in lua.c. I have lua_initVM
which sets up the lua_State instance, loads the script into it, and
calls the "init" function from the script. That's working fine. Then I
have the lua_frameVM function which is simply supposed to call the
"frame" function from the script. However, ANY operation on my lua_State
instance which occurs outside the lua_initVM function is causing a
segfault. Even though the lua_State instance is declared as a global.
What am I doing wrong here?