Icon representing a recipe

Recipe: version print

created by brgreening

Profile


Name
version print
ID
47844
Shared with
Public
Parent
None
Children
None
Created on
January 23, 2014 at 03:58 AM UTC
Updated on
January 23, 2014 at 03:58 AM UTC
Description

this prints the Lua Version

Best for


Code


-- DO NOT RUN THIS SCRIPT -- it is for demonstrating that a bad Lua script -- can crash Foldit -- It demonstrates that an invalid argument for os.date( "%Q" ) or -- doing a divide by zero in a Lua script can crash Foldit -- It crashes when using Lua 5.1. This crashes for the current 1/22/2014 version of Foldit -- Using Lua 5.2 in the Windows Lua compiler gets around this. -- This bug is mentioned in https://fold.it/portal/node/996624 print( "Lua Version: ", _VERSION ) x_str = os.date( "%X" ) print( "Valid argument for Lua os.date() works ", x_str ) x1_val = 1.0 x2_val = 3.0 print( "Doing divide with non-zero divisor: ", x1_val / x2_val ) x2_val = 0.0 print( "Attempting divide with zero divisor: ", x1_val / x2_val ) -- **** this will crash Foldit **** x_str = os.date( "%Q" ) -- **** this will crash Foldit ***** print( "Invalid argument for Lua os.date() ", x_str )

Comments


brgreening Lv 1

This script is to demonstrate that an invalid argument to the os.date( "%Q" ) statement in a Lua script or attempting to divide by zero in a Lua script will crash Foldit. I was running Foldit under Windows 8. I would be interested in
what this script does in Linux or on a Mac.

Current Foldit uses Lua 5.1.

I downloaded Lua 5.2 and ran it using Windows Lua compiler. The errors seem to be handled better there. It prints out an error message rather than crashing.

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.