<?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>13071</bug_id>
          
          <creation_ts>2018-12-10 17:54:47 +0000</creation_ts>
          <short_desc>Multiconfig builds may try to execute events that don&apos;t exist for them</short_desc>
          <delta_ts>2021-02-23 23:25:34 +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>3.3 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alejandro Hernandez">alejandr</reporter>
          <assigned_to name="Alejandro">alejandro</assigned_to>
          <cc>Adrian.Fiergolski</cc>
    
    <cc>alejandro</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</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>82462</commentid>
    <comment_count>0</comment_count>
    <who name="Alejandro Hernandez">alejandr</who>
    <bug_when>2018-12-10 17:54:47 +0000</bug_when>
    <thetext>I thought this was a complicated bug to reproduce, so I will try to give some context before to explain what is happening:

When launching a multiconfig build, the metadata is parsed n+1 times (where n is the number of configurations that will be built), there is a respective local.conf for each configuration (including the main local.conf, which I will call default).

Which means that if we enable a multiconfig build, and only build one configuration, we will have two local.conf files, the default one and the one that contains the configuration that we want to build, e.g. conf/local.conf and conf/multiconfig/arm.conf.

Both configurations may contain INHERITs, either on local.conf or any other conf files that are parsed at parse time.

Some of these INHERITs may contain event handlers, e.g. buildhistory.

So, if the default configuration contains INHERIT += &quot;buildhistory&quot; for example, the default configuration will have an event called buildhistory_eventhandler(), the first thing this event does is:
e.data.getVar(&apos;BUILDHISTORY_FEATURES&apos;).strip(), so it tries to access the data that was parsed and get the variable BUILDHISTORY_FEATURES from it, this variable is literally the first thing that is declared on buildhistory.bbclass.

Assuming the other configuration, does not INHERIT buildhistory, that configuration won&apos;t have parsed the buildhistory.bbclass file, hence the variable BUILDHISTORY_FEATURES won&apos;t be declared for it.

The problem is, that the event buildhistory_eventhandler(), is executed by bitbake for that configuration as well, resulting in the following error:


ERROR: Execution of event handler &apos;buildhistory_eventhandler&apos; failed
Traceback (most recent call last):
  File &quot;meta/classes/buildhistory.bbclass&quot;, line 801, in buildhistory_eventhandler(e=&lt;bb.event.BuildStarted object at 0x7f5e529c40b8&gt;):
     python buildhistory_eventhandler() {
    &gt;    if e.data.getVar(&apos;BUILDHISTORY_FEATURES&apos;).strip():
             reset = e.data.getVar(&quot;BUILDHISTORY_RESET&quot;)
AttributeError: &apos;NoneType&apos; object has no attribute &apos;strip&apos;

ERROR: Command execution failed: Traceback (most recent call last):
  File &quot;bitbake/lib/bb/command.py&quot;, line 116, in runAsyncCommand
    commandmethod(self.cmds_async, self, options)
  File &quot;bitbake/lib/bb/command.py&quot;, line 608, in buildTargets
    command.cooker.buildTargets(pkgs_to_build, task)
  File &quot;bitbake/lib/bb/cooker.py&quot;, line 1479, in buildTargets
    bb.event.fire(bb.event.BuildStarted(buildname, ntargets), self.databuilder.mcdata[mc])
  File &quot;bitbake/lib/bb/event.py&quot;, line 225, in fire
    fire_class_handlers(event, d)
  File &quot;bitbake/lib/bb/event.py&quot;, line 134, in fire_class_handlers
    execute_handler(name, handler, event, d)
  File &quot;bitbake/lib/bb/event.py&quot;, line 106, in execute_handler
    ret = handler(event)
  File &quot;meta/classes/buildhistory.bbclass&quot;, line 801, in buildhistory_eventhandler
    if e.data.getVar(&apos;BUILDHISTORY_FEATURES&apos;).strip():
AttributeError: &apos;NoneType&apos; object has no attribute &apos;strip&apos;



Which basically means that the variable BUILDHISTORY_FEATURES doesnt exist for this build (which is ok).


Interestingly, this cannot be reproduced if the default configuration (local.conf), INHERITs buildhistory,it HAS to INHERIT it from one of the other config files that were parsed, for example the distro.conf (poky.conf).


I created a contrib branch to make it easier to reproduce, on which I create a copy of poky.conf called poky-mctest.conf that is literally just a copy of poky.conf with an extra INHERIT += &quot;buildhistory&quot; and added some warnings for debugging purposes: http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=aehs29/multiconfig_events_bug


As a summary, to reproduce this, the default/main local.conf should contain the following:

BBMULTICONFIG ?= &quot;arm&quot; # only one multiconfig build should be enough
DISTRO= &quot;poky-mctest&quot;

There also has to be a matching conf file for the arm build on conf/multiconfig/arm.conf, that NEEDS to be building a different DISTRO, so it doesnt parse the same extra buildhistory.bbclass as the default will:

DISTRO=&quot;poky&quot;
MACHINE=&quot;qemuarm&quot;
TMPDIR=&quot;${TOPDIR}/tmparm&quot;


This should not be specific for buildhistory, that is just an example, any class with an event like that should cause the same problem (uninative maybe?)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89363</commentid>
    <comment_count>1</comment_count>
    <who name="Alejandro">alejandro</who>
    <bug_when>2021-02-23 23:25:34 +0000</bug_when>
    <thetext>Fixed here:

https://git.openembedded.org/bitbake/commit/?id=5f7fdf7b2d8c59805c8ef4dae84f536baa5e172b</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>