#43724: Segfault with cyclic requirements in self-provided goods Open Date: 2022-01-28 15:33 Last Update: 2022-02-04 01:30 URL for this Ticket: https://osdn.net//projects/freeciv/ticket/43724 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43724 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2022-02-04 01:30 Updated by: alienvalkyrie Comment: Reply To cazfi This is not the first recursive requirement (though I don't remember the other one(s) from the top of my head). The sanity check should be generic enough to catch any complex infinite recursion over different requirement types (Good 1 requirement -> Type B requirement -> Good 2 requirement -> Type C requirement -> Good 1 requirement) Even if it is generic enough, that only really works fine for the case where at every step along that chain, the relevant requirement (whether present or not) can only be fulfilled in one specific way – in more general cases (like the example above) the sanity check would have to realize, based on the contradictory terrain class requirements, that infinite recursion isn't possible... until we evaluate against something where the terrain class requirements become TRI_MAYBE and we have to recurse into the goods requirement anyway. Hm. Point is, if we want to make this sanity check without being overly restrictive, it'd have to explore a (possibly very large) tree of ways that certain requirements (particularly negated ones) could be fulfilled, while keeping in mind all the facts that already have to be given to even reach that test. I'm not sure that's such a sensible thing to do. So really, the two options we have (as far as I can tell) are making recursive requirements statically impossible (in particular, reverting Self-Provided goods and replacing them with some other solution), or adding infinite-recursion-detection to the requirement checker (e.g. building a list of everything that's currently being evaluated in is_req_active) The latter would also mean we'd have to decide on what to do in case of infinite recursion – in particular, when something negatively depends on itself. --------------------------------------------------------------------- Ticket Status: Reporter: alienvalkyrie Owner: (None) Type: Bugs Status: Open Priority: 5 - Medium MileStone: S3_2 d3f Component: General Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: With the self-provided goods introduced in #43532, infinite recursion is possible via is_req_active -> is_goods_type_in_range -> goods_can_be_provided -> are_reqs_active -> is_req_active if ruleset authors include cyclic dependencies between self-provided goods. This should probably be caught with sanity checks when loading the ruleset rather than crashing. -- Ticket information of Freeciv project Freeciv Project is hosted on OSDN Project URL: https://osdn.net/projects/freeciv/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/freeciv/ticket/43724 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43724