Failed to Perform Mandatory Yield error in long running script.
tracked
SungAli Resident
After running continuously for several weeks, my emulator script halted with this error:
A Simple Sun-Earth-Moon emulator.: 0.3 [script:Sun-Earth-Moon demo] Script run-time error
Failed to perform mandatory yield
lua_script:159 function emulation_step
[C] function _tick
[C] function timer_event_wrapper
[C] function _handleEvent
The script, or an earlier version thereof, has halted similarly on at least two previous occasions. This, however, is the first time I've been on Sim when the crash occurred to receive the error message.
Full script @ https://pastebin.com/PAg61t1K
The instance of the object that crashed is at https://maps.secondlife.com/secondlife/Builders%20Brewery%20Sandbox/36/69/498 Anyone may take a full perms copy. I have not reset the script.
Log In
SungAli Resident
Further observations: When running a group of test scripts that will crash, the original Earth-Moon-Sun object nearby also crashes more frequently, indicating a probable interaction among scripts. However timing measures don't support the idea that any such interaction is the sole cause of crashes, that is, a single script can, and seemingly usually does, crash itself.
In the test script the ll.GetPos call outside of the ll.SetLinkPrimitilveParamsFast call seems to be critical. Variations without that call do not crash over test intervals as long as 12 hours with 64 instances running. Even substituting equivalent code setting and reading the object's rotation instead of position results in a stable run. However, the timer driven loop in which the Earth-Moon-Sun script is running when it crashes, contains no calls to ll.GetPos at all. This, together with the clustering of failures when many instances are running, suggests the possibility that if ll.GetPos is specifically involved, then a call to ll.GetPos in one script may impact ll.SetLinkPrimitiveParamsFast in other scripts. This would be consistent with the low failure rate of the Earth-Moon-Sun script when I'm not testing.
There is jitter in the timing data that I currently have due to the scripts being started over an interval of several seconds (see my bug report about Drag-Copy) and each measuring its own time. I need to rerun the tests with the scripts started as close to each other as possible to minimize this jitter and get a better view of any clustering of failures. Or, perhaps better, use the ll.GetTimestamp() real time at start value as an offset to correct time measures among scripts.
SungAli Resident
PS. The problem was not observed when running 64 instances of a script with colliding timers and with the scripts reset en-masse and running together.
SungAli Resident
The problem appears to be a collision in overlapping occurrences of ll.SetLinkPrimitiveParamsFast (executing asynchronously of the script). 64 instances of the following script running together can produce the error in a few minutes:
local base = ll.GetPos()
while true do
ll.SetLinkPrimitiveParamsFast( LINK_THIS, {PRIM_POSITION, vector(math.random()-0.5, 0, 0) + (base + ll.GetPos())/2 } )
ll.SetLinkPrimitiveParamsFast( LINK_THIS, {PRIM_POSITION, vector(0, math.random()-0.5, 0) + (base + ll.GetPos())/2 } )
ll.SetLinkPrimitiveParamsFast( LINK_THIS, {PRIM_POSITION, vector(0, 0, math.random()-0.5) + (base + ll.GetPos())/2 } )
ll.SetText( tostring(ll.GetPos()-base), vector(1,1,1), 1 )
end--while
SungAli Resident
I restarted the object after a while. The error continues to occur on a period of days to weeks.
M
Mercury Linden
updated the status to
tracked
M
Mercury Linden
updated the status to
under review