Bug 14355 - Conditional append to distro feature causes infinite recursion parsing error
Summary: Conditional append to distro feature causes infinite recursion parsing error
Status: RESOLVED WONTFIX
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 5.99
Assignee: Unassigned
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2021-04-21 13:02 UTC by richard.neill
Modified: 2026-04-30 16:27 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description richard.neill 2021-04-21 13:02:45 UTC
On poky master (6204a3f5f4), either of these lines:

DISTRO_FEATURES_append_machine = " ${@bb.utils.contains('DISTRO_FEATURES', 'feature', ' another_feature', '', d)}"

DISTRO_FEATURES_machine += "${@bb.utils.contains('DISTRO_FEATURES', 'feature', 'another_feature', '', d)}"

Results in a parse error where it infinitely parses the conditional code:

$ bitbake feature-image-minimal
ERROR: Unable to parse <expansion>
Traceback (most recent call last):
  File "/home/<user>/project/poky/bitbake/lib/bb/data_smart.py", line 416, in DataSmart.expandWithRefs(s="  feature ${@bb.utils.contains('DISTRO_FEATURES', 'feature', ' another_feature', '', d)}", varname='DISTRO_FEATURES'):
                     tb = sys.exc_info()[2]
    >                raise ExpansionError(varname, s, exc).with_traceback(tb) from exc
     
  File "/home/<user>/project/poky/bitbake/lib/bb/data_smart.py", line 403, in DataSmart.expandWithRefs(s="  feature ${@bb.utils.contains('DISTRO_FEATURES', 'feature', ' another_feature', '', d)}", varname='DISTRO_FEATURES'):
                     try:
    >                    s = __expand_python_regexp__.sub(varparse.python_sub, s)
                     except SyntaxError as e:
  File "/home/<user>/project/poky/bitbake/lib/bb/data_smart.py", line 116, in VariableParse.python_sub(match=<re.Match object; span=(20, 96), match="${@bb.utils.contains('DISTRO_FEATURES', 'feature>):
     
    >            parser = bb.codeparser.PythonParser(self.varname, logger)
                 parser.parse_python(code)
  File "/home/<user>/project/poky/bitbake/lib/bb/codeparser.py", line 279, in PythonParser.__init__(name='DISTRO_FEATURES', log=<BBLogger BitBake.Data (Level 8)>):
             self.references = set()
    >        self.log = BufferedLogger('BitBake.Data.PythonParser', logging.DEBUG, log)
     
  File "/home/<user>/project/poky/bitbake/lib/bb/codeparser.py", line 184, in BufferedLogger.__init__(name='BitBake.Data.PythonParser', level=10, target=<BBLogger BitBake.Data (Level 8)>):
         def __init__(self, name, level=0, target=None):
    >        Logger.__init__(self, name)
             self.setLevel(level)
bb.data_smart.ExpansionError: Failure expanding variable DISTRO_FEATURES, expression was   feature ${@bb.utils.contains('DISTRO_FEATURES', 'feature', ' another_feature', '', d)} which triggered exception RecursionError: maximum recursion depth exceeded

This also occurs if I use a temporary variable to store the result of the conditional, and append the value of that temporary variable to DISTRO_FEATURES for the machine.

My rationale for doing this is that we have some dependent layers, and we need 'another_feature' known by the parser (for a particular machine) even if the layer implementing 'feature' (which has a dependency on 'another_feature') is optionally later in bblayers.conf. 

Regardless of the rationale, provided the inclusion isn't breaking any rules then I would expect it to either succeed or fail gracefully?
Comment 1 Randy MacLeod 2021-04-22 14:46:10 UTC
This is an edge with a stack that explains what's going wrong but maybe we can improve how it's handled.
Comment 2 Randy MacLeod 2023-10-30 15:37:32 UTC
Build move to 5.0 -- ../Randy
Comment 3 Randy MacLeod 2024-04-25 01:13:52 UTC
Bulk move of 5.0 medium importance issues to 5.99.
Move to 5.1 if you want to actively work on an issue.
Comment 4 Randy MacLeod 2024-04-25 01:23:15 UTC
Move to 5.99 since no one is actively working on this issue.
Move to 5.x if you start on a task, please.
Comment 5 Richard Purdie 2026-04-30 16:27:44 UTC
We don't support circular references and realistically, I don't think we can unfortunately so this is something we can't fix.