<?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>12816</bug_id>
          
          <creation_ts>2018-06-28 00:23:49 +0000</creation_ts>
          <short_desc>layer without priority causes crash instead of reporting error</short_desc>
          <delta_ts>2018-10-01 21:45:57 +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.6 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Reyna">david.reyna</reporter>
          <assigned_to name="David Reyna">david.reyna</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</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>80936</commentid>
    <comment_count>0</comment_count>
    <who name="David Reyna">david.reyna</who>
    <bug_when>2018-06-28 00:23:49 +0000</bug_when>
    <thetext>In &quot;cooker.py&quot; there is a section of code that scans a layer for its priority.

However, only the success path avoids an otherwise undefined variable, so the error is not reported and bitbake crashes. This was found while experimenting with a weak layer.
  
  UnboundLocalError: local variable &apos;cre&apos; referenced before assignment

Here is the code in question. Notice that &apos;cre&apos; is only defined on the success path.

vvvvvvv
# Calculate all layer priorities using calc_layer_priority and store in bbfile_config_priorities
for c in collection_list:
    calc_layer_priority(c)
    regex = self.data.getVar(&quot;BBFILE_PATTERN_%s&quot; % c)
    if regex == None:
        parselog.error(&quot;BBFILE_PATTERN_%s not defined&quot; % c)
        errors = True
        continue
    elif regex == &quot;&quot;:
        parselog.debug(1, &quot;BBFILE_PATTERN_%s is empty&quot; % c)
        errors = False
    else:
        try:
            cre = re.compile(regex)
        except re.error:
            parselog.error(&quot;BBFILE_PATTERN_%s \&quot;%s\&quot; is not a valid regular expression&quot;, c, regex)
            errors = True
            continue
    self.bbfile_config_priorities.append((c, regex, cre, collection_priorities[c]))
^^^^^^^^

I propose that the resolution is to move the append right after &apos;cre&apos; is defined, since that is the only success path.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81690</commentid>
    <comment_count>1</comment_count>
    <who name="David Reyna">david.reyna</who>
    <bug_when>2018-10-01 21:45:57 +0000</bug_when>
    <thetext>This was fixed by this commit:

  commit fe70fd1a03dcbf516ee10866b8a68daf942c0a07
  Author: Robert Yang &lt;liezhi.yang@windriver.com&gt;
  Date:   Thu Feb 1 23:15:22 2018 +0800

    bitbake: bitbake: cooker: skip when BBFILE_PATTERN is empty</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>