nginx:[错误] 无法初始化 Lua 虚拟机

nginx: [error] failed to initialize Lua VM

我正在尝试使用以下命令检查我的 nginx 模块中的内存泄漏 valgrind.I 我正在尝试以下命令

valgrind --leak-check=full --tool=memcheck --show-reachable=yes --log-file="/tmp/val.out" -v /usr/local/nginx -c /usr/local/conf/nginx.conf

我收到错误 nginx:[错误] 初始化失败 Lua VM

我在 Cent OS 7 wit lua 0.9.15.

上使用 nginx-1.6.2

我遇到了同样的问题,通过升级 Valgrind 并向 LuaJIT 编译添加一些额外的标志来解决。

调查:

  • https://github.com/openresty/lua-nginx-module/issues/681
    具体来说:

    • ==52538== Using Valgrind-3.10.0 and LibVEX;

    • Your version of valgrind does not support the MAP_32BIT flag required by LuaJIT's own allocator. You need either an older version of valgrind (like 3.8.1) or a newer version (like 3.11.0).

  • https://groups.google.com/forum/#!topic/openresty/riEO_YXTwz4
    具体来说(使用 Google 翻译):

    This is because LuaJIT own memory allocator MAP_32BIT use this flag in Linux x86_64 above to call mmap () System call. And Valgrind 3.9.0 is no longer supported from the mmap MAP_32BIT this flag, it will make LuaJIT Initialization failed.

    The solution is to re-compile a special version of LuaJIT, force it to use a dispenser system, using a command like this at compile time LuaJIT:

    make CCDEBUG=-g Q= XCFLAGS='-DLUAJIT_USE_VALGRIND -DLUAJIT_USE_SYSMALLOC'

    Here the most important thing is LUAJIT_USE_SYSMALLOC this macro. Of course, for best results, you should also specify the following C compiler options:

    -DLUA_USE_APICHECK -DLUA_USE_ASSERT