Search code examples
luavalgrindluajit

luaL_newstate doesn't succeed under valgrind?


I'm trying to debug some problems with a luajit based application under 64bit Linux.

The script calls back into a number of libraries via FFI and I'm trying to figure out some memory corruption issues. Valgrind is normally my tool of choice for this, however I've found that luaL_newstate fails when run under Valgrind.

After some poking around I found that standard luajit also fails to load. I think this might be more a problem with valgrind than luajit. Is there a way of giving valgrind more memory?


Solution

  • If you are using a version of valgrind starting with version 3.9.0 and up to (but not including) version 3.11.0 that is likely the problem.

    Those versions appear to be "broken" on x86_64 with luajit.

    See this email from Mike Pall:

    [Note that Valgrind 3.9.0 has chosen to block MAP_32BIT, which breaks LuaJIT on Linux/x64:

    https://bugs.kde.org/show_bug.cgi?id=324181

    Older versions of Valgrind still work. It wasn't that useful to debug LuaJIT on x64, anyway, due to the mandatory use of the builtin allocator. But none of that relates to your problem.]