lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Peter Odding <peter <at> peterodding.com> writes:
> Anyway, to get to my point: I'm thinking my problem is related to 
> allocating memory in one thread and then trying to deallocate the memory 
> in another thread (either that or a race condition between the memory 
> allocators of both threads). Might this be your problem as well?

Thanks a lot for the suggestion Peter.  In my case I am not spawning any
threads.  In fact I get the same crash if my Lua program does nothing but:

  require "upb"

And I should have mentioned this in my original email, but I can reproduce
the crash even when my luaopen_upb is:

  int luaopen_upb(lua_State *L) {
    lua_createtable(L, 0, 0);
    return 1;  // Return package table.
  }

However, the crash goes away if I change this to:

  int luaopen_upb(lua_State *L) {
    return 0;
  }

This leads me to believe that it's got to be something about how I'm
building the extension.  But what?  My build/link line is:

  gcc -std=c99 -Isrc -Itests -I. -Wall -Wextra -Wno-missing-field-initializers 
  -I/usr/include/lua5.1 -fpic -shared -o lang_ext/lua/upb.so lang_ext/lua/upb.c
  src/libupb_pic.a -L/usr/local/lib -llua

Maybe I shouldn't be linking against Lua at this point -- since the lua
binary is already linked against it, maybe I'm loading Lua twice as Luiz
suggested.  But if I don't link against Lua at this point I get undefined
reference errors (even though I'm compiling with -shared).

Josh