lua-users home
lua-l archive

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


> > mt = getmetatable(io.stdin)
> > p = newproxy()
> > debug.setmetatable(p, mt)
> > p:read()
> Segmentation fault (core dumped)
> 
> I don't really feel it's a bug as someone with access to the debug
> interface should be responsible and not do things this stupid, but I
> thought I'd throw this out there...

That's exactly why Lua does not normally allow setmetatable for userdata:
it breaks C data safety.

The debug library is just for that, debugging. If you expose it to your app,
then anything goes, including segmentation faults, which are usually a very
big no-no for embedded languages.
--lhf