Bug: io.open fails on empty file name

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug: io.open fails on empty file name

Jonne Ransijn
Steps to reproduce:
1.    Create program containing: io.open("", "")
2.    Execute program
Expected result:
error: file name cannot be empty
Actual result:
crash: lua.exe doesn't react
NB: I couldn't find a actual bug report platform, and my experience with the mailing list has learnt me that there aren't many bug reports here. I hope this is the right place; http://www.lua.org/faq.html#2.3 wasn't very specific.
Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Thijs Schreijer

What Lua version, what os and what version...

Op 29 mrt. 2015 23:15 schreef Jonne Ransijn <[hidden email]>:
Steps to reproduce:
1.    Create program containing: io.open("", "")
2.    Execute program
Expected result:
error: file name cannot be empty
Actual result:
crash: lua.exe doesn't react
NB: I couldn't find a actual bug report platform, and my experience with the mailing list has learnt me that there aren't many bug reports here. I hope this is the right place; http://www.lua.org/faq.html#2.3 wasn't very specific.
Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Jonne Ransijn
Lua 5.1.4, Windows 8.1

2015-03-29 23:36 GMT+02:00 Thijs Schreijer <[hidden email]>:

What Lua version, what os and what version...

Op 29 mrt. 2015 23:15 schreef Jonne Ransijn <[hidden email]>:
Steps to reproduce:
1.    Create program containing: io.open("", "")
2.    Execute program
Expected result:
error: file name cannot be empty
Actual result:
crash: lua.exe doesn't react
NB: I couldn't find a actual bug report platform, and my experience with the mailing list has learnt me that there aren't many bug reports here. I hope this is the right place; http://www.lua.org/faq.html#2.3 wasn't very specific.

Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Jonne Ransijn

2015-03-30 0:07 GMT+02:00 Jonne Ransijn <[hidden email]>:
Lua 5.1.4, Windows 8.1

2015-03-29 23:36 GMT+02:00 Thijs Schreijer <[hidden email]>:

What Lua version, what os and what version...

Op 29 mrt. 2015 23:15 schreef Jonne Ransijn <[hidden email]>:
Steps to reproduce:
1.    Create program containing: io.open("", "")
2.    Execute program
Expected result:
error: file name cannot be empty
Actual result:
crash: lua.exe doesn't react
NB: I couldn't find a actual bug report platform, and my experience with the mailing list has learnt me that there aren't many bug reports here. I hope this is the right place; http://www.lua.org/faq.html#2.3 wasn't very specific.


Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Jonathan Goble
I get the same result in Lua 5.1.4 on Win8.1. However, the bug does
not occur in 5.3.0 on Ubuntu 14.04; Lua instead throws an error "bad
argument #2 to 'open' (invalid mode)".

On Sun, Mar 29, 2015 at 6:45 PM, Jonne Ransijn <[hidden email]> wrote:

> http://i.imgur.com/sdtLAyU.png
>
> 2015-03-30 0:07 GMT+02:00 Jonne Ransijn <[hidden email]>:
>>
>> Lua 5.1.4, Windows 8.1
>>
>> 2015-03-29 23:36 GMT+02:00 Thijs Schreijer <[hidden email]>:
>>>
>>> What Lua version, what os and what version...
>>>
>>> Op 29 mrt. 2015 23:15 schreef Jonne Ransijn <[hidden email]>:
>>> Steps to reproduce:
>>> 1.    Create program containing: io.open("", "")
>>> 2.    Execute program
>>> Expected result:
>>> error: file name cannot be empty
>>> Actual result:
>>> crash: lua.exe doesn't react
>>> NB: I couldn't find a actual bug report platform, and my experience with
>>> the mailing list has learnt me that there aren't many bug reports here. I
>>> hope this is the right place; http://www.lua.org/faq.html#2.3 wasn't very
>>> specific.
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Luiz Henrique de Figueiredo
In reply to this post by Jonne Ransijn
This is the right place to report bugs.

> 1.    Create program containing: io.open("", "")
> 2.    Execute program
> Expected result:
> error: file name cannot be empty
> Actual result:
> crash: lua.exe doesn't react

Do you actually get a crash or just no response from lua.exe?

Try changing the program to
        print(io.open("", ""))

With this change, I get
        bad argument #2 to 'open' (invalid mode)
as expected.

Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Jonne Ransijn
Its a crash, not a error. I included a screenshot showing the exact behaviour on a Windows 8.1 laptop with Lua 5.1.4 installed. However, it seems like the bug has already been fixed in Lua 5.3, so I dont know how big of a problem this crash acturely is. Maybe it would be wise to release a new version of Lua 5.1 where this crash is fixed, but thats not up to me.
Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Jonathan Goble
In reply to this post by Luiz Henrique de Figueiredo
On Sun, Mar 29, 2015 at 6:54 PM, Luiz Henrique de Figueiredo
<[hidden email]> wrote:
> Try changing the program to
>         print(io.open("", ""))
>
> With this change, I get
>         bad argument #2 to 'open' (invalid mode)
> as expected.


Again, it crashes in Lua 5.1.4 on Windows 8.1. Screenshot:
http://snag.gy/bPlCZ.jpg

Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Jonathan Goble
On Sun, Mar 29, 2015 at 7:03 PM, Jonathan Goble <[hidden email]> wrote:

> On Sun, Mar 29, 2015 at 6:54 PM, Luiz Henrique de Figueiredo
> <[hidden email]> wrote:
>> Try changing the program to
>>         print(io.open("", ""))
>>
>> With this change, I get
>>         bad argument #2 to 'open' (invalid mode)
>> as expected.
>
>
> Again, it crashes in Lua 5.1.4 on Windows 8.1. Screenshot:
> http://snag.gy/bPlCZ.jpg

And Lua 5.1.5 on Ubuntu 14.04: http://snag.gy/d9jJI.jpg Doesn't even
throw an error.

Summary:
Lua 5.1.4/Windows 8.1 = interpreter crash
Lua 5.1.5/Ubuntu 14.04 = nothing
Lua 5.3.0/Ubuntu 14.04 = bad argument error

I suspect that the lack of catching the error in 5.1.x is the problem,
which was apparently fixed in either 5.2 or 5.3. Ubuntu is able to
recover and fail silently, but Windows can't. So this is most likely a
Windows issue. (It could also be a problem with the LuaForWindows
distribution, as that's what I'm using on my Windows machine.)

Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Scott Morgan
On 30/03/15 00:15, Jonathan Goble wrote:
> On Sun, Mar 29, 2015 at 7:03 PM, Jonathan Goble <[hidden email]> wrote:
>> On Sun, Mar 29, 2015 at 6:54 PM, Luiz Henrique de Figueiredo
>> <[hidden email]> wrote:
>>> Try changing the program to
>>>         print(io.open("", ""))
>>>
...
> I suspect that the lack of catching the error in 5.1.x is the problem,
> which was apparently fixed in either 5.2 or 5.3. Ubuntu is able to
> recover and fail silently, but Windows can't. So this is most likely a
> Windows issue. (It could also be a problem with the LuaForWindows
> distribution, as that's what I'm using on my Windows machine.)

Just tried running a copy in a debugger (MSVC2010), the error is being
thrown from the MSVCR100.DLL fopen function, it's trapping the empty
mode string in an assert.

MSVC2010 : fopen
https://msdn.microsoft.com/en-us/library/yeby3zcb%28v=vs.100%29.aspx

Which references 'Parameter Validation':
https://msdn.microsoft.com/en-us/library/ksazx244%28v=vs.100%29.aspx

Scott


Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Luiz Henrique de Figueiredo
In reply to this post by Jonne Ransijn
> it seems like the bug has already been fixed in Lua 5.3, so I dont know how
> big of a problem this crash acturely is.

The problem is that some C libraries crash when fopen is given invalid modes.
Lua 5.2 protected Lua from such annoying behavior by testing the modes it gets.
See http://www.lua.org/source/5.2/liolib.c.html#lua_checkmode .

> Maybe it would be wise to release a new version of Lua 5.1 where this
> crash is fixed

Lua 5.1 is no longer in development. The last release was 5.1.5.
There won't be another release of 5.1.

If you want this fixed, use Lua 5.2 or 5.3.

Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Xpol Wan
Same result for luajit 2.0.3 compiled with msvc 12 (vs 2013) running on windows 7.
Luiz Henrique de Figueiredo <[hidden email]>于2015年3月30日 周一07:57写道:
> it seems like the bug has already been fixed in Lua 5.3, so I dont know how
> big of a problem this crash acturely is.

The problem is that some C libraries crash when fopen is given invalid modes.
Lua 5.2 protected Lua from such annoying behavior by testing the modes it gets.
See http://www.lua.org/source/5.2/liolib.c.html#lua_checkmode .

> Maybe it would be wise to release a new version of Lua 5.1 where this
> crash is fixed

Lua 5.1 is no longer in development. The last release was 5.1.5.
There won't be another release of 5.1.

If you want this fixed, use Lua 5.2 or 5.3.

Reply | Threaded
Open this post in threaded view
|

RE: Bug: io.open fails on empty file name

Thijs Schreijer
In reply to this post by Jonathan Goble


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Jonathan Goble
> Sent: maandag 30 maart 2015 0:50
> To: Lua mailing list
> Subject: Re: Bug: io.open fails on empty file name
>
> I get the same result in Lua 5.1.4 on Win8.1. However, the bug does
> not occur in 5.3.0 on Ubuntu 14.04; Lua instead throws an error "bad
> argument #2 to 'open' (invalid mode)".
>

Tested with;
 - Lua 5.1.5,
 - on Win7-64bit

Executing;
 - print(io.open("", ""))

When;
 - compiled using MinGW; works as expected; "Invalid argument" error
 - compiled using Win7 SDK; crashes


Thijs
Reply | Threaded
Open this post in threaded view
|

Re: Bug: io.open fails on empty file name

Tim Channon
In reply to this post by Jonathan Goble
On 30/03/2015 00:15, Jonathan Goble wrote:

> On Sun, Mar 29, 2015 at 7:03 PM, Jonathan Goble <[hidden email]> wrote:
>> On Sun, Mar 29, 2015 at 6:54 PM, Luiz Henrique de Figueiredo
>> <[hidden email]> wrote:
>>> Try changing the program to
>>>          print(io.open("", ""))
>>>
>>> With this change, I get
>>>          bad argument #2 to 'open' (invalid mode)
>>> as expected.
>>
>>
>> Again, it crashes in Lua 5.1.4 on Windows 8.1. Screenshot:
>> http://snag.gy/bPlCZ.jpg
>
> And Lua 5.1.5 on Ubuntu 14.04: http://snag.gy/d9jJI.jpg Doesn't even
> throw an error.
>
> Summary:
> Lua 5.1.4/Windows 8.1 = interpreter crash
> Lua 5.1.5/Ubuntu 14.04 = nothing
> Lua 5.3.0/Ubuntu 14.04 = bad argument error
>
> I suspect that the lack of catching the error in 5.1.x is the problem,
> which was apparently fixed in either 5.2 or 5.3. Ubuntu is able to
> recover and fail silently, but Windows can't. So this is most likely a
> Windows issue. (It could also be a problem with the LuaForWindows
> distribution, as that's what I'm using on my Windows machine.)
>


Reported okay with minGW
Reports Invalid argument here for 5.1.5 under W8.1 64 but compiled
openwatcom 2.0

OS is fine, library used is not.