Comment 3 for bug 573178

Revision history for this message
SirVer (sirver) wrote :

I found the problem with this. The pairs() and ipairs() functions return a c closure that continues the iteration. As there is a sleep() inside the for iteration, the save will always occur while we are inside the iteration. short code to reproduce the crash:

function blah()
  for i,v in ipairs{1} do sleep(300) end
end

this will crash at any save. I currently do not see a way around this besides reimplementing pairs() and ipairs() in pure lua (which I am not sure if this works) and overriding the default c functions or adding a warning to the documentations (very risky) or completely disabling ipairs and pairs (which suckz, because iterating an array becomes difficult, iterating a dictionary practically impossible).