lua-users home
lua-l archive

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


Hi all,

I'm trying to link LuaJIT into an application on 64-bit Mac OS X.  Following the instructions on the LuaJIT website, I've added

    -pagezero_size 10000

to the linker flags; if I don't, I get a segfault when trying to open a new lua_State.

Unfortunately, doing this means that I can no longer run my app in valgrind, since it requires the executable to have the default pagezero_size.  You get the following error message:

    bad executable (__PAGEZERO is not 4 GB)

The comments from the appropriate part of the valgrind source:

    // Don't honour the client's request to map PAGEZERO.  Why not?
    // Because when the kernel loaded the valgrind tool executable,
    // it will have mapped pagezero itself.  So further attempts
    // to map it when loading the client are guaranteed to fail.

One thought that I had was that (from what I can tell) the pagezero_size flag is only needed by LuaJIT's custom allocator — so if I use a different allocator, I wouldn't have to pass in that flag.  (Not necessarily the *system* allocator; when I was using the standard Lua interpreter, I used glib's g_slice functions.)  But you can't call lua_newstate on x64, even if you pass in a custom lua_Alloc func.

So I'm at an impasse.  I'd love to be able to both (a) use LuaJIT in my app, and (b) run valgrind on it.  Any thoughts on how to proceed?  How big of a change would it be to make LuaJIT's allocator not require pagesize_zero, or to have LuaJIT work with a custom allocator on x64?

Many thanks,
–doug

Attachment: PGP.sig
Description: This is a digitally signed message part