lua-users home
lua-l archive

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


On Wed, Jun 01, 2016 at 02:57:07PM +0200, Heinrich Hartmann wrote:
<snip>
> https://github.com/LuaDist/lpeg/pull/1
> 
> """
> On operating systems like Solaris and Illumos where the stack grows down,
> lightuserdata and user data cannot be assigned from the stack. This commit
> patch fixes this behaviour by moving the allocations to the heap (using
> calloc).
> 
> We also ran into symbol collisions (compile) when linking the library with
> our codebase. This is also addressed in a separate commit.
> 
> """

Does Solaris or Illumos guarantee that calloc/malloc always fill requests
from the lowest regions available? What if it can't because the lowest 4GBs
are already allocated? Wouldn't it make more sense to use the allocator
returned by lua_getallocf?

I would assume that LuaJIT will by default return a lua_Alloc that
guarantees suitably located allocations, or fails trying. That's what the
LuaJIT 2.0.3 source code shows--luaL_newstate passing it's internal
allocator (lj_alloc_f) to lua_newstate.