lua-users home
lua-l archive

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


Hi,

> >"cannot read lua/freepops.lua: No error"
> 
> The "No error" is reported by strerror. It is typically the value
> corresponding to errno=0.

The #1 cause for unexpected errno=0 is that a different C library function 
is overwriting the value before it is accessed.

In src/lib/lauxlib.c:errfile() is a call to lua_tostring() *before* using
strerror(errno). This is a bit dangerous since lua_tostring() may invoke 
C library functions. The solution is obvious:

...
  const char *s = strerror(errno);
  const char *filename = lua_tostring(L, fnameindex) + 1;
  lua_pushfstring(L, "cannot read %s: %s", filename, s);
...

But I don't understand how this could be the cause for this problem.
The filename on the stack is already a string, so no C library function
needs to be called? Strange ....

Does the problem go away, when the change is applied?

Bye,
     Mike