View Issue Details

IDProjectCategoryView StatusLast Update
0003801Spring engineUnit Scriptingpublic2014-01-30 09:35
ReporterIthoughtWeBannedHim Assigned TojK  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionwon't fix 
Summary0003801: allow recursion in lua calls: [CreateUnit()]: recursion is not permitted()
Description[CreateUnit()]: recursion is not permitted()

This is bad and can be worked around by simply pushing those creates on a stack..
so please remove it?

https://github.com/spring/spring/blob/ff55956c1c915128c7e590887883decbc4a89d4a/rts/Lua/LuaSyncedCtrl.cpp

Line Number 925..
YetTodoStack.push(this.createUnitCall)..
TagsNo tags attached.
Checked infolog.txt for Errors

Activities

abma

2013-05-21 19:04

administrator   ~0010725

what does 82.7 and following mean?

the code that disallows recursion exists since > 6 years
https://github.com/spring/spring/commit/87be45f5d14dfc0dfd609983d9d4624b8492e44c#L134R757

i guess its there because recursion would lead to really ugly errors. i don't have the internal knowledge, but imo this won't be changed...

user744

2013-05-22 11:47

  ~0010745

"i guess its there because recursion would lead to really ugly errors."
but only if the Gadget code is bad and causes endless recursion?

I do not see why something like this should not be allowed:

function gadget:UnitCreated(...)
 if newUnitsDefID == unitA then Spring.CreateUnit (unitB) end
end

This only causes "1 Level deep recursion" before it Returns, yet it is not allowed.

Similiar GiveOrder is not allowed within AllowCommand()

I think Gadgets should be trusted enought not to create endless loops...

IthoughtWeBannedHim

2013-05-23 21:58

reporter   ~0010752

Its only recursion if it has to happen in the same frame, basically messing up the lua-order of execution by mid gadget adding more units who, would in turn call again the gadget. (Lua:Gadget:UnitCreated(bla,blu,blaeben)

So its understandable.
What is not reasonable is to deny the unitspawning therefore alltogether. Just add the unitspawncomand to a stack that gets executed once the gadgetshift has been worked off. And im sorry, but for some stuff (decals, buildanimations) recursion is really necessary..

FLOZi

2014-01-30 00:10

reporter   ~0012782

1. Is about more than recursion

2. Easily overcome in a safe way lua side

-> "no change needed" / "won't fix" ?

Issue History

Date Modified Username Field Change
2013-05-21 16:00 IthoughtWeBannedHim New Issue
2013-05-21 19:04 abma Note Added: 0010725
2013-05-21 20:29 abma Priority high => normal
2013-05-21 20:29 abma Severity major => feature
2013-05-21 20:29 abma Status new => feedback
2013-05-22 11:47 user744 Note Added: 0010745
2013-05-23 21:58 IthoughtWeBannedHim Note Added: 0010752
2013-05-23 21:58 IthoughtWeBannedHim Status feedback => new
2013-05-25 02:49 abma Summary 82.7 and following => allow recursion in lua calls: [CreateUnit()]: recursion is not permitted()
2014-01-30 00:10 FLOZi Note Added: 0012782
2014-01-30 09:35 jK Status new => closed
2014-01-30 09:35 jK Assigned To => jK
2014-01-30 09:35 jK Resolution open => won't fix