<?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>10399</bug_id>
          
          <creation_ts>2016-10-07 22:10:20 +0000</creation_ts>
          <short_desc>bitbake is unable to handle exceptions past the clean_environment() call</short_desc>
          <delta_ts>2017-12-06 17:11:08 +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>
          
          <see_also>https://bugzilla.yoctoproject.org/show_bug.cgi?id=10397</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>High</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>2.2 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Benjamin Esquivel">benjamin.esquivel</reporter>
          <assigned_to name="Aníbal Limón">anibal.limon</assigned_to>
          <cc>brian.avery</cc>
    
    <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>67069</commentid>
    <comment_count>0</comment_count>
    <who name="Benjamin Esquivel">benjamin.esquivel</who>
    <bug_when>2016-10-07 22:10:20 +0000</bug_when>
    <thetext>When bitbake --server-only is called, any exception, handled or unhandled; that occurs after this line: 

  cleanedvars = bb.utils.clean_environment()

from bitbake/lib/bb/main.py, produces an infinite loop of cleanliness.

An example of this is bug 10397.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67070</commentid>
    <comment_count>1</comment_count>
    <who name="Benjamin Esquivel">benjamin.esquivel</who>
    <bug_when>2016-10-07 22:18:59 +0000</bug_when>
    <thetext>An induced example of this bug can be found at the poky-contrib branch besquive/such-clean:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=besquive/such-clean

which places a handled exception right after the point where it will loop endlessly.

it is worth noting that the exception could happen on further lines than this induced example, like with bug 10397.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67242</commentid>
    <comment_count>2</comment_count>
    <who name="Benjamin Esquivel">benjamin.esquivel</who>
    <bug_when>2016-10-13 21:11:41 +0000</bug_when>
    <thetext>Forgot to add the steps to reproduce:

1. clone the git repo
2. get the code from the besquive/such-clean branch (stimulates an exception)
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=besquive/such-clean
3. run the init build env script
4. start a bitbake server, i.e.
 $ bitbake --server-only -t xmlrpc -B localhost:1234
5. watch the fireworks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67243</commentid>
    <comment_count>3</comment_count>
    <who name="Aníbal Limón">anibal.limon</who>
    <bug_when>2016-10-13 21:34:04 +0000</bug_when>
    <thetext>The loop is on, 

File &quot;/home/alimon/repos/pokyro/bitbake/lib/bb/event.py&quot;, line 158, in print_ui_queue

Due of that function is called atexit, if you move the registry of bb.event.LogHandler after bb.utils.clean_environment() it will fix the problem because clean_environment() is calling logger.debug, more investigation is needed.

diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py
index 19ee729..992e879 100755
--- a/bitbake/lib/bb/main.py
+++ b/bitbake/lib/bb/main.py
@@ -435,19 +435,15 @@ def bitbake_main(configParams, configuration):
     bb.msg.init_msgconfig(configParams.verbose, configuration.debug,
                           configuration.debug_domains)
 
+    # Clear away any spurious environment variables while we stoke up the cooker
+    cleanedvars = bb.utils.clean_environment()
+
     # Ensure logging messages get sent to the UI as events
     handler = bb.event.LogHandler()
     if not configParams.status_only:
         # In status only mode there are no logs and no UI
         logger.addHandler(handler)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67245</commentid>
    <comment_count>4</comment_count>
    <who name="Aníbal Limón">anibal.limon</who>
    <bug_when>2016-10-13 22:04:20 +0000</bug_when>
    <thetext>The bug is caused because bb.event.LogHandler adds events to ui_queue when is called causing an infinite loop when interate over ui_queue at print_ui_queue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67246</commentid>
    <comment_count>5</comment_count>
    <who name="Aníbal Limón">anibal.limon</who>
    <bug_when>2016-10-13 22:05:04 +0000</bug_when>
    <thetext>Also happens in bitbake proceess not only server mode.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67249</commentid>
    <comment_count>6</comment_count>
    <who name="Aníbal Limón">anibal.limon</who>
    <bug_when>2016-10-13 23:12:07 +0000</bug_when>
    <thetext>Patch sent to,

http://lists.openembedded.org/pipermail/bitbake-devel/2016-October/008153.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67295</commentid>
    <comment_count>7</comment_count>
    <who name="Aníbal Limón">anibal.limon</who>
    <bug_when>2016-10-17 14:47:23 +0000</bug_when>
    <thetext>Fixed at,

http://git.openembedded.org/bitbake/commit/?id=46fecca9d531a07788b5cac8b2dc6a8267d8b6d0</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>