lua-users home
lua-l archive

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


> On 2 June 2016 at 04:25, Heinrich Hartmann
> <heinrich@heinrichhartmann.com> wrote:
> > LuaJIT supports Solaris/Illumos, with the single caveat that one
> > cannot use lightuserdata on the stack. While LuaJIT was very
> > accommodating to changes required to support
> > Solaris/Illumos, this particular incompatibility is not something that
> > can be fixed easily:
> > LuaJIT uses pointer compaction and does not support pointers using high bits.
> > Illumos and its derivatives use high bits on stack memory: they are
> > just incompatible!
> >
> > So, if lpeg wants to support Solaris/Illumus it has to avoid using
> > lightusedata residing the stack.
> >
> > Fortunately, the problem very easy to circumvent on the application
> > side, by making surgical changes that are easy to reason about, as in
> > the PR.
> 
> I'm surprised that it works as well as you indicate.
> Especially when targeting lua 5.1, pushing stack-allocated
> lightuserdata is essential for safe operation (see lua_cpcall).
> 
> It sounds like you may want to send some resources towards
> https://github.com/LuaJIT/LuaJIT/issues/156

I also do not understand why it should be so hard to fix that problem in
JuaJIT. As long as the stack is smaller than some huge limit (probably
2^30 or 2^31), one single bit should be enough to distinguish between
stack-allocated and other lightuserdata. When pushing lightuserdata,
LuaJIT already checks whether the lightuserdata is in the stack (to
raise an error); when retrieving userdata, I imagine it already has to
check the value's type anyway, so again the overhead seems quite small.

-- Roberto