lua-users home
lua-l archive

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


>I'm not sure if this qualifies as a bug, but lua_pushcclosure doesn't verify
>that the upvalues actually exist on the stack.  If they don't then invalid
>values will be put on the stack for the function call, causing a crash if
>they are accessed.

This is not a bug; it's by design. :-)
We make a point that a host program cannot be crashed from Lua, but when
you're writing in C, you can crash the program in a thousand different ways,
eg. by passing NULL as a state, and "hand-helding" is neither sufficient nor
necessary. So, there are no API errors anymore.
This makes the code simpler and the API faster.

This also follows the C tradition of no "hand-helding", eg. in standard C
library: try using a NULL FILE* in stdio functions or overflowing buffers
in sprintf or strcat and you crash.

It should be possible to write a "hand-helding" wrapper API. We might add
this as an optional, separate module.
--lhf