an improperly typed Lua script can crash Foldit

Started by brgreening

brgreening Lv 1

This is a line in a LUA script by John McLeod

print(os.date("started %I:%M:%S %p %a %b %d, %Y")) – this LUA Script works well

I substituted a %l for the %I

print(os.date("started %l:%M:%S %p %a %b %d, %Y")) – this LUA Script crashes Foldit

In Windows 8, I get a box that says "A problem caused the program to stop working correctly.
Windows will close the program and notify you if a solution is found". The Foldit program is
terminated.

(a) Is this actually a Windows bug? What happens if this tried on a Linux or Mac machine?

brgreening Lv 1

I typed in upper case I (as in India) in the first LUA script and
lower case l in in (lima bean) in the second LUA script.

brgreening Lv 1

I typed in upper case I as in India in the first line
and lower case l as in lima bean in the second line

brgreening Lv 1

I ran Lua 5.1.1 on my computer and got the same bug.

I downloaded Lua 5.2.1 and tried the thing again and it was gone on Lua version 5.2.1.
What version of Lua currently runs with FoldIt?
Can I specify what version of Lua that runs with Foldit on my machine?


Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio

print( os.date() )
01/13/14 13:14:35
print( os.date( "%I" ) )
01
print( os.date( "%l" ) )
stdin:1: bad argument #1 to 'date' (invalid conversion specifier '%l')
stack traceback:
[C]: in function 'date'
stdin:1: in main chunk
[C]: in ?

My input comment screen had a font of New Courrier so that I as in India was easily
distinguishable form l as in lima bean.
This time I clicked on "Preview" and the output had a font of New Courrier.
Will the text on the FoldIt Feedback screen be in New Courrier so that I and l are easy
to tell apart?

brow42 Lv 1

It's interesting that you found stock Lua libraries to crash. Foldit has a custom wrapper around print to add spaces between arguments, I would expect some error checking would need to be added to Foldit's wrapper. Perhaps it still does, if the libraries have an error.

brgreening Lv 1

The bug is not in Lua's print() it is in Lua's os.date( "%Q" ). Calling os.date() with an invalid
argument causes it. I ran it using Lua's version 5.1 Windows compiler and got the bug too.
I upgraded to the
latest version of Lua Windows Compiler which is 5.2.1 and the os.date() bug is fixed. The current release of Foldit
and NewChapter Foldit use Lua version 5.1.

I wrote a Lua script that would divide by zero. It crashed Foldit too.

Output from Lua Windows Compiler:

Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio

x_str = os.date( "%X" )
print( x_str )
10:29:07
x_str = os.date( )
print( x_str )
01/22/14 10:29:53
x_str = os.date( "%Q" )
stdin:1: bad argument #1 to 'date' (invalid conversion specifier '%Q')
stack traceback:
[C]: in function 'date'
stdin:1: in main chunk
[C]: in ?

print( "Lua version: ", _VERSION )
Lua version: Lua 5.2

brgreening Lv 1

The software release,
20140811-46cd6bb2fb-win_x86-devprev,
Fixed these bugs.

Lua Version: Lua 5.1
Foldit run on this date: 08/11/14 15:29:58
Valid table index: 902
Invalid table index: nil
Valid argument for Lua os.date() works 15:29:58
Doing divide with non-zero divisor: 0.33333333333333
Attempting divide with zero divisor: 1.#INF
Invalid argument for Lua os.date() 15:29:58

http://fold.it/portal/recipe/47844

a recipe called “version print” has been created to test these functions

There is no indication as to where the error occurred. Lua is compiled into a series of function calls when executed. Something like “Divide by zero in function check_helix + 128 “ would be nice.