Icon representing a recipe

Recipe: SSCrasher 1.0

created by LociOiling

Profile


Name
SSCrasher 1.0
ID
103227
Shared with
Public
Parent
None
Children
None
Created on
January 11, 2020 at 20:57 PM UTC
Updated on
January 11, 2020 at 20:57 PM UTC
Description

Crashes the Foldit client by attempting to set the secondary structure of an invalid segment.

Best for


Code


--[[ SSCrasher - recipe to crash client by setting secondary structure Causes a crash on 20191029-32048a6a12-win_x86-devprev, puzzle 1784. Also demonstrates use of xpcall with cleanup function. version 1.0 -- 2020/01/11 -- LociOiling * new recipe ]]-- -- -- define the main routine -- -- main does not start executing until it's called by the xpcall statement, -- which is the very last line in the recipe -- function main () Recipe = "SSCrasher" -- recipe name Version = "1.0" -- recipe version ReVersion = Recipe .. " " .. Version -- combined name and version print ( ReVersion .. " start" ) -- start the scriptlog output local len = structure.GetCount () print ( "segment count = " .. len ) -- actual number of segments -- -- try to set the secondary structure of the segment beyond the end -- -- this should cause an exception, which will be caught by the cleanup function -- -- it may also crash the Foldit client -- print ( "attempting to crash Foldit by setting invalid segments to loop" ) for ii = len + 1, len * 2 do print ( "setting segment " .. ii ) -- record last segment structure.SetSecondaryStructure ( ii, "L" ) -- set segment to loop end print ( "no crash, disappointing in a way" ) cleanup () -- always clean up after yourself end -- -- define the cleanup routine -- -- the cleanup routine is specified on the xpcall below, -- but doesn't run until an exception occurs or the main -- routine finishes and calls it -- function cleanup ( errmsg ) if CLEANUPENTRY ~= nil then return end CLEANUPENTRY = true print ( "---" ) local reason local start, stop, line, msg if errmsg == nil then reason = "complete" else -- -- civilized error reporting, thanks to Bruno K. and Jean-Bob -- start, stop, line, msg = errmsg:find ( ":(%d+):%s()" ) if msg ~= nil then errmsg = errmsg:sub ( msg, #errmsg ) end if errmsg:find ( "Cancelled" ) ~= nil then reason = "cancelled" else reason = "error" end end print ( ReVersion .. " " .. reason ) if reason == "error" then print ( "Unexpected error detected" ) print ( "Error line: " .. line ) print ( "Error: \"" .. errmsg .. "\"" ) end end -- -- the xpcall below is the first executable statement -- -- it calls function main, which controls execution -- from then on -- -- if something in function generates an exception, -- function cleanup is invoked -- xpcall ( main, cleanup )

Comments


LociOiling Lv 1

This recipe crashes the Windows client, buildid 20191029-32048a6a12-win_x86-devprev, on puzzle 1784.

Puzzle 1784 has 188 segments, and the recipe attempts to set the secondary structure for segment 189.

The recipe uses the xpcall function, and includes a cleanup routine. Normally, an error like specifying an invalid segment generates an exception, which is then caught by the cleanup routine if you're using xpcall. The usual approach is to then simply end the recipe. The recipe is done, but the client keeps running.

In this case, the cleanup routine is invoked, and reports the error as expected. The client also crashes after this, which is unexpected.

See feedback setting secondary structure of invalid segment crashes client.