<?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>12987</bug_id>
          
          <creation_ts>2018-11-07 11:43:25 +0000</creation_ts>
          <short_desc>Remove variables containing shell substitutions from vardeps of shell function if it cannot be expanded</short_desc>
          <delta_ts>2019-01-23 16:36:38 +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>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.7 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Frederik Noe-Sdun">frederik.sdun</reporter>
          <assigned_to name="Christopher Larson">kergoth</assigned_to>
          <cc>kergoth</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>82046</commentid>
    <comment_count>0</comment_count>
      <attachid>4384</attachid>
    <who name="Frederik Noe-Sdun">frederik.sdun</who>
    <bug_when>2018-11-07 11:43:25 +0000</bug_when>
    <thetext>Created attachment 4384
put into classes directory

If a shell function uses substitution contaning changing variables the metadata is not deterministic and bitbake yields following error messages:

ERROR: When reparsing /home/frederik/src/git/poky/meta/recipes-connectivity/openssl/openssl_1.1.1.bb.do_foobar, the basehash value changed from 828eb1721ee1d58febebc7ab86d02778 to 06428c477fa2268fe4b68541f85e764b. The metadata is not deterministic and this needs to be fixed.
ERROR: openssl-1.1.1-r0 do_foobar: Taskhash mismatch 09143e58ed1ef42a04311d69cd4a3a7b versus 36573c975a2aa5b6568e07169bdec6fd for /home/frederik/src/git/poky/meta/recipes-connectivity/openssl/openssl_1.1.1.bb.do_foobar
ERROR: Taskhash mismatch 09143e58ed1ef42a04311d69cd4a3a7b versus 36573c975a2aa5b6568e07169bdec6fd for /home/frederik/src/git/poky/meta/recipes-connectivity/openssl/openssl_1.1.1.bb.do_foobar

bitbake does not prohibit using special characters like %#% in variable names and above error message may not be obvious and hard to debug.

Attached class can be used to reproduce the issue if inherited.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82176</commentid>
    <comment_count>1</comment_count>
    <who name="Christopher Larson">kergoth</who>
    <bug_when>2018-11-12 15:47:58 +0000</bug_when>
    <thetext>I have a fix for this implemented at https://github.com/openembedded/bitbake/compare/master...kergoth:yocto-12987, but I&apos;m going to do a bit more profiling and performance testing to determine the impact, and may switch to a hasattr approach to avoid the set existing even when none of these were found, as they&apos;re relatively rare in our metadata.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82809</commentid>
    <comment_count>2</comment_count>
    <who name="Christopher Larson">kergoth</who>
    <bug_when>2019-01-16 18:58:46 +0000</bug_when>
    <thetext>After looking at this again, it become obvious that the current prototype implementation is far from ideal since it adds an extra wordlist-to-string, uses another set, and duplicates logic that&apos;s already in bitbake&apos;s own variable parsing.

An easier method is to check for and block references based on the existence of certain parameter modifier characters in build_dependencies instead, but even that doesn&apos;t seem ideal, and we can&apos;t exclude all parameter modifiers, as some are valid in variable names. For example, we allow &apos;-&apos;, but ${foo-bar} has a specific parameter expansion in shell, so that&apos;s not ideal either.

I think an even better approach than that is actually just to stop trying to expand references to variable names which aren&apos;t valid bitbake variable names according to our own parser. That&apos;d avoid adding references to names with #, %, etc, without adding extra logic beyond the regex. I&apos;m testing and benchmarking that option now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82810</commentid>
    <comment_count>3</comment_count>
    <who name="Christopher Larson">kergoth</who>
    <bug_when>2019-01-16 20:46:01 +0000</bug_when>
    <thetext>Reworked patch at https://github.com/openembedded/bitbake/compare/master...kergoth:yocto-12987-new, pending submission to the bitbake-devel list shortly, after I complete bitbake-selftest + oe-selftest -a and a bit more benchmarking.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82829</commentid>
    <comment_count>4</comment_count>
    <who name="Christopher Larson">kergoth</who>
    <bug_when>2019-01-18 16:47:56 +0000</bug_when>
    <thetext>Sent to bitbake-devel for review.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4384</attachid>
            <date>2018-11-07 11:43:25 +0000</date>
            <delta_ts>2018-11-08 17:01:40 +0000</delta_ts>
            <desc>put into classes directory</desc>
            <filename>shell-substitution.bbclass</filename>
            <type>text/plain</type>
            <size>154</size>
            <attacher name="Frederik Noe-Sdun">frederik.sdun</attacher>
            
              <data encoding="base64">TVlfRk9PQkFSUyA9ICJmb28tJHtEQVRBVElNRX0gYmFyLSR7REFURVRJTUV9Igpkb19mb29iYXIo
KSB7CiAgICBmb3IgZiBpbiAke01ZX0ZPT0JBUlN9IDsgZG8gCiAgICAgICAgYmFzZT0iJHtmIy0k
e0RBVEFUSU1FfX0iCiAgICBkb25lCn0KCmFkZHRhc2sgZm9vYmFyCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>