Lua 5.1.4 (not jit) + LuaFFI (support needed)


  • Hello, I don't really know where I should be asking this but I only know this forum so I thought I could talk about it here.
    My problem is this: I managed to build LuaFFI (https://github.com/jmckaskill/luaffi), under MinGW (gcc 3.4.5).

    It certainly does load correctly, but for whatever reason the program crashes when lua_close is called on the state.

    The program doesn't have a Makefile for MinGW. I used this shell commands in order to compile it:
    gcc -c call.c
    gcc -c ctype.c
    gcc -c ffi.c
    gcc -c parser.c

    Afterwards I downloaded liblua5.1.a from LuaBinaries (the 32 bit MinGW distribution one). And installed it on MinGW/lib/

    I had all the object files compiled and the source code of Lua 5.1.4 stored in the "src" folder inside of the same folder as the sources of the LuaFFI module.

    I wasn't quite sure what the problem was with GetModuleHandleEx/GetModuleHandle (they weren't defined anywhere) so I had to remove them from ffi.c (I thought it not so important) and recompile ffi.c.

    Finally I used this to get the dll object.
    gcc -O -shared -o ffi.dll *.o -L src -llua5.1

    The program that is using ffi.dll, is using a unmodified version of Lua 5.1.4 (and it's a static library, compiled with MinGW too).

    • I don't think that the issue is related to the program itself because it is able to load any other modules as many times as it wants to without causing crashes.
    • I discard the option that another module using functions from ffi.dll could be causing the crash because I immediately closed the state after loading doing "require'ffi'".
    • However, I think that the garbage collector is messing up with the module (ffi.dll) and I'm not really sure about how I'm going to fix that.

    Any ideas? (Please think of me as a ignorant on this topic, I'm just a regular Lua coder)


  • 2
    Posts
    881
    Views
    Log in to reply


  • After checking: https://luapower.com/build-scripts
    I realized that I had followed very similar steps, but this time I decided to build liblua51.a by myself (The size of the file increased by few kilobytes). Apparently the problem persists.


2
Posts
881
Views
Log in to reply

Internal error.

Oops! Looks like something went wrong!