lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
>
> > I just noticed, lua-5.1-rc has the same problems with errno: between
> > the syscall setting errno and the usage of errno there are several
> > function calls that may destroy its value (i.e. lua_push* may call
> > lockmutex, malloc, generate fp-errors, etc).  And ferror doesn't set
> > errno at all.
> 
> * lockmutex: users use this facility at their own risk...

Those were only examples.  I took lockmutex just to show that
simple functions like lua_pushnil may eventually change errno.
Afaics, lua_pushstring may even call the garbage collector and
invoke GC methods.

How about a note in the manual: No API function preserves errno.


> * malloc: as far as I know, a correct malloc should not change errno.

I wouldn't bet a dime on that :-)


> * "And ferror doesn't set errno at all." What is the point here?

Code like:

  if (ferror(f))
    return luaL_error(L, "%s", strerror(errno));

There are more places, just grep for ferror.


> We will try to improve that.

Considering that nobody has noticed it in a lot of years I guess
it's not that urgent.

Ciao, ET.