<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14355</bug_id>
          
          <creation_ts>2021-04-21 13:02:45 +0000</creation_ts>
          <short_desc>Conditional append to distro feature causes infinite recursion parsing error</short_desc>
          <delta_ts>2026-04-30 16:27:44 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>5.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>richard.neill</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>90039</commentid>
    <comment_count>0</comment_count>
    <who name="">richard.neill</who>
    <bug_when>2021-04-21 13:02:45 +0000</bug_when>
    <thetext>On poky master (6204a3f5f4), either of these lines:

DISTRO_FEATURES_append_machine = &quot; ${@bb.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;feature&apos;, &apos; another_feature&apos;, &apos;&apos;, d)}&quot;

DISTRO_FEATURES_machine += &quot;${@bb.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;feature&apos;, &apos;another_feature&apos;, &apos;&apos;, d)}&quot;

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

$ bitbake feature-image-minimal
ERROR: Unable to parse &lt;expansion&gt;
Traceback (most recent call last):
  File &quot;/home/&lt;user&gt;/project/poky/bitbake/lib/bb/data_smart.py&quot;, line 416, in DataSmart.expandWithRefs(s=&quot;  feature ${@bb.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;feature&apos;, &apos; another_feature&apos;, &apos;&apos;, d)}&quot;, varname=&apos;DISTRO_FEATURES&apos;):
                     tb = sys.exc_info()[2]
    &gt;                raise ExpansionError(varname, s, exc).with_traceback(tb) from exc
     
  File &quot;/home/&lt;user&gt;/project/poky/bitbake/lib/bb/data_smart.py&quot;, line 403, in DataSmart.expandWithRefs(s=&quot;  feature ${@bb.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;feature&apos;, &apos; another_feature&apos;, &apos;&apos;, d)}&quot;, varname=&apos;DISTRO_FEATURES&apos;):
                     try:
    &gt;                    s = __expand_python_regexp__.sub(varparse.python_sub, s)
                     except SyntaxError as e:
  File &quot;/home/&lt;user&gt;/project/poky/bitbake/lib/bb/data_smart.py&quot;, line 116, in VariableParse.python_sub(match=&lt;re.Match object; span=(20, 96), match=&quot;${@bb.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;feature&gt;):
     
    &gt;            parser = bb.codeparser.PythonParser(self.varname, logger)
                 parser.parse_python(code)
  File &quot;/home/&lt;user&gt;/project/poky/bitbake/lib/bb/codeparser.py&quot;, line 279, in PythonParser.__init__(name=&apos;DISTRO_FEATURES&apos;, log=&lt;BBLogger BitBake.Data (Level 8)&gt;):
             self.references = set()
    &gt;        self.log = BufferedLogger(&apos;BitBake.Data.PythonParser&apos;, logging.DEBUG, log)
     
  File &quot;/home/&lt;user&gt;/project/poky/bitbake/lib/bb/codeparser.py&quot;, line 184, in BufferedLogger.__init__(name=&apos;BitBake.Data.PythonParser&apos;, level=10, target=&lt;BBLogger BitBake.Data (Level 8)&gt;):
         def __init__(self, name, level=0, target=None):
    &gt;        Logger.__init__(self, name)
             self.setLevel(level)
bb.data_smart.ExpansionError: Failure expanding variable DISTRO_FEATURES, expression was   feature ${@bb.utils.contains(&apos;DISTRO_FEATURES&apos;, &apos;feature&apos;, &apos; another_feature&apos;, &apos;&apos;, 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 &apos;another_feature&apos; known by the parser (for a particular machine) even if the layer implementing &apos;feature&apos; (which has a dependency on &apos;another_feature&apos;) is optionally later in bblayers.conf. 

Regardless of the rationale, provided the inclusion isn&apos;t breaking any rules then I would expect it to either succeed or fail gracefully?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90056</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-04-22 14:46:10 +0000</bug_when>
    <thetext>This is an edge with a stack that explains what&apos;s going wrong but maybe we can improve how it&apos;s handled.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97152</commentid>
    <comment_count>2</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-10-30 15:37:32 +0000</bug_when>
    <thetext>Build move to 5.0 -- ../Randy</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98820</commentid>
    <comment_count>3</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-04-25 01:13:52 +0000</bug_when>
    <thetext>Bulk move of 5.0 medium importance issues to 5.99.
Move to 5.1 if you want to actively work on an issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98883</commentid>
    <comment_count>4</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-04-25 01:23:15 +0000</bug_when>
    <thetext>Move to 5.99 since no one is actively working on this issue.
Move to 5.x if you start on a task, please.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105334</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2026-04-30 16:27:44 +0000</bug_when>
    <thetext>We don&apos;t support circular references and realistically, I don&apos;t think we can unfortunately so this is something we can&apos;t fix.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>