[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua crashing on unrecognized strings
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 27 Aug 2009 16:06:16 -0300
> On Tue, Aug 25, 2009 at 4:50 PM, David Manura<dm.lua@math2.org> wrote:
> > On Mon, Aug 24, 2009 at 9:03 AM, Peter Cawley wrote:
> >> Likewise, io.open wraps fopen, and if the
> >> underlying C runtime explodes on invalid input, then so will Lua.
> >
> > I came across that a few weeks ago actually. io.open(name, 'wa') crashed [1].
> >
> > [1] http://luadist.svn.sourceforge.net/viewvc/luadist/trunk/dists/luadist-1.0.0/lmod/dist/log.lua?view=patch&r1=304&r2=303&pathrev=304
> >
>
> Is that legal?
>
> I would assumed the documented behaviour on Linux
>
> ERRORS
> EINVAL The mode provided to fopen(), fdopen(), or freopen() was invalid.
>
> Would be the ANSI defined behaviour.
ISO/IEC 9899:1999 (E) says this (Section 7.19.5.3):
The argument 'mode' points to a string. If the string is one of the
following, the file is open in the indicated mode. Otherwise, the
behavior is undefined.
r open text file for reading
...
This is very sad, but "the behavior is undefined" actually means that.
(Even crashing is acceptable.)
-- Roberto