0

I currently have a problem where Lua5.1/Lua5.2 can load & use a module, but LuaJIT can't. This is strange, since LuaJIT should be ABI-compatible to Lua, right?

How could I fix this?

The module: https://github.com/gabrield/v4l-lua

max1220
  • 44
  • 5
  • Can you show us the backtrace from the crash and any error messages that go along with it? – Etan Reisner Jul 23 '15 at 13:30
  • @max1220: Are you using the Makefile from the repository? If so you can try removing the `-llua5.1` from the compile command line. – siffiejoe Jul 23 '15 at 13:40
  • Which Lua library did you link to your module? Interpreter & module should use the same Lua C API functions internally. – Youka Jul 23 '15 at 22:50
  • @EtanReisner: I'd like to: [pastebin.com](http://pastebin.com/tkVVnh5Y). I don't think that helpful though. – max1220 Jul 24 '15 at 09:28
  • @siffiejoe: Yes, I build it using the makefile. But even when manually building using `gcc -Wall -pedantic -fPIC v4l_lua.c core.c -shared -o v4l2.so -I /usr/include/lua5.1/ -lv4lconvert`, I still get the same error. – max1220 Jul 24 '15 at 09:29
  • @Youka: Lua5.1, as you can see above. It should be ABI compatible with LuaJIT though. – max1220 Jul 24 '15 at 09:31
  • For non-germans: his error message just tells "Memory Access Violation" - that's all. That means the library file was found, entry function `luaopen_v4l` is available... and then sth. terrible happens. What confuses me is how [lua_settable](https://github.com/gabrield/v4l-lua/blob/master/v4l_lua.c#L136) is used in C. – Youka Jul 24 '15 at 10:18
  • @max1220: The `lua_settable` call per se is correct -- it just does something strange and useless -- but it causes the following `return 1` to be incorrect because there is nothing left on the Lua stack to return. This might just cause the SIGSEGV you're experiencing, so you should remove it (or alternatively change `return 1` to `return 0`). – siffiejoe Jul 24 '15 at 12:11
  • That's just the error not a backtrace. A backtrace is going to be more useful. – Etan Reisner Jul 24 '15 at 13:10
  • That lua_settable call isn't correct. There aren't enough things on the stack for it to work correctly. It pops two items but needs another to set them into (unless it is well defined for it to work on itself). – Etan Reisner Jul 24 '15 at 13:11

1 Answers1

0

I solved it by simply removing the settable line in v4l_lua.c (line). Thanks to @Youka, @siffiejoe and @Etan-Reisner for the suggestion!

I wonder though why Lua loaded the module without even a warning(And have it working to!)

max1220
  • 44
  • 5