<?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>7398</bug_id>
          
          <creation_ts>2015-03-05 10:58:37 +0000</creation_ts>
          <short_desc>toaster: Infinite loop error handling issues</short_desc>
          <delta_ts>2015-04-17 11:34:42 +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>Toaster</product>
          <component>toaster</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</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>1.8 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Richard Purdie">richard.purdie</reporter>
          <assigned_to name="Alexandru Damian">alexandru.damian</assigned_to>
          <cc>alexandru.damian</cc>
    
    <cc>belen.barros.pena</cc>
    
    <cc>cristiana.voicu</cc>
    
    <cc>jessica.zhang</cc>
    
    <cc>stanciux.mihail</cc>
          
          <qa_contact name="Mihail Stanciu">stanciux.mihail</qa_contact>
          <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>49198</commentid>
    <comment_count>0</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-03-05 10:58:37 +0000</bug_when>
    <thetext>If you change buildhistory with something like:

--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -371,16 +371,16 @@ buildhistory_get_installed() {
rm $1/depends.tmp
# Produce installed package sizes list
- printf &quot;&quot; &gt; $1/installed-package-sizes.tmp
- cat $pkgcache | while read pkg pkgfile pkgarch
- do
- size=`oe-pkgdata-util -p ${PKGDATA_DIR} read-value &quot;PKGSIZE&quot; ${pkg}_${pkgarch}`
- if [ &quot;$size&quot; != &quot;&quot; ] ; then
- echo &quot;$size $pkg&quot; &gt;&gt; $1/installed-package-sizes.tmp
- fi
- done
- cat $1/installed-package-sizes.tmp | sort -n -r | awk &apos;{print $1 &quot;\tKiB &quot; $2}&apos; &gt; $1/installed-package-sizes.txt
- rm $1/installed-package-sizes.tmp
+ #printf &quot;&quot; &gt; $1/installed-package-sizes.tmp
+ #cat $pkgcache | while read pkg pkgfile pkgarch
+ #do
+ # size=`oe-pkgdata-util -p ${PKGDATA_DIR} read-value &quot;PKGSIZE&quot; ${pkg}_${pkgarch}`
+ # if [ &quot;$size&quot; != &quot;&quot; ] ; then
+ # echo &quot;$size $pkg&quot; &gt;&gt; $1/installed-package-sizes.tmp
+ # fi
+ #done
+ #cat $1/installed-package-sizes.tmp | sort -n -r | awk &apos;{print $1 &quot;\tKiB &quot; $2}&apos; &gt; $1/installed-package-sizes.txt
+ #rm $1/installed-package-sizes.tmp

then the installed-packages-sizes.txt file isn&apos;t generated.

If you then build an image with toaster running, it enters an infinite loop when it can&apos;t find the file:

ERROR: Execution of event handler &apos;toaster_buildhistory_dump&apos; failed
Traceback (most recent call last):
  File &quot;toaster_buildhistory_dump(e)&quot;, line 20, in toaster_buildhistory_dump(e=&lt;bb.event.BuildCompleted object at 0x7f1a92de7e50&gt;)
IOError: [Errno 2] No such file or directory: &apos;/media/build1/poky/build/buildhistory/images/qemux86/glibc/core-image-sato/installed-package-sizes.txt&apos;


Keyboard Interrupt, closing down...

NOTE: Tasks Summary: Attempted 5550 tasks of which 5271 didn&apos;t need to be rerun and all succeeded.
NOTE: Writing buildhistory
ERROR: Execution of event handler &apos;toaster_buildhistory_dump&apos; failed
Traceback (most recent call last):
  File &quot;toaster_buildhistory_dump(e)&quot;, line 20, in toaster_buildhistory_dump(e=&lt;bb.event.BuildCompleted object at 0x7f1a94186090&gt;)
IOError: [Errno 2] No such file or directory: &apos;/media/build1/poky/build/buildhistory/images/qemux86/glibc/core-image-sato/installed-package-sizes.txt&apos;

NOTE: Tasks Summary: Attempted 5550 tasks of which 5271 didn&apos;t need to be rerun and all succeeded.
NOTE: Writing buildhistory
ERROR: Execution of event handler &apos;toaster_buildhistory_dump&apos; failed
Traceback (most recent call last):
  File &quot;toaster_buildhistory_dump(e)&quot;, line 20, in toaster_buildhistory_dump(e=&lt;bb.event.BuildCompleted object at 0x7f1a92e34850&gt;)
IOError: [Errno 2] No such file or directory: &apos;/media/build1/poky/build/buildhistory/images/qemux86/glibc/core-image-sato/installed-package-sizes.txt&apos;


I&apos;m don&apos;t mind it breaking if I make changes like this on my own, that is fair enough but the error handling needs improving do it doesn&apos;t loop infinitely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49199</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-03-05 11:17:25 +0000</bug_when>
    <thetext>Possible fix:

From 13172dbf979276c39bd62c7144d4fcd6d09bf09e Mon Sep 17 00:00:00 2001
From: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;
Date: Thu, 5 Mar 2015 11:16:55 +0000
Subject: event: Improve exception handling?

Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index fec6a05..62a8f4f 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -74,17 +74,17 @@ def execute_handler(name, handler, event, d):
     event.data = d
     try:
         ret = handler(event)
-    except (bb.parse.SkipRecipe, bb.BBHandledException):
+    except bb.parse.SkipRecipe:
         raise
+    except bb.BBHandledException:
+        pass
     except Exception:
         etype, value, tb = sys.exc_info()
         logger.error(&quot;Execution of event handler &apos;%s&apos; failed&quot; % name,
                         exc_info=(etype, value, tb.tb_next))
-        raise
     except SystemExit as exc:
         if exc.code != 0:
-            logger.error(&quot;Execution of event handler &apos;%s&apos; failed&quot; % name)
-        raise
+            logger.error(&quot;Execution of event handler &apos;%s&apos; failed (exit code %s)&quot; % (name, exc.code))
     finally:
         del event.data
 
-- 
cgit v0.10.2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49205</commentid>
    <comment_count>2</comment_count>
    <who name="Alexandru Damian">alexandru.damian</who>
    <bug_when>2015-03-05 12:57:20 +0000</bug_when>
    <thetext>Good spot for the bug ! Thanks for the patch - I want to see if we can handle it in ToasterUI, or how does it impact the managed mode building.

Moving the bug to accepted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49216</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-03-05 15:02:54 +0000</bug_when>
    <thetext>You can likely make the class more forgiving but I think there is also a general problem, if an event handler raises an exception, cooker can be left looping infinitely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49268</commentid>
    <comment_count>4</comment_count>
    <who name="Alexandru Damian">alexandru.damian</who>
    <bug_when>2015-03-06 15:48:45 +0000</bug_when>
    <thetext>Alternative patch pushed for review at:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=adamian/20150305_review&amp;id=a75e421a6c5857629b44c7b7dd92ae00a0e46677</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49907</commentid>
    <comment_count>5</comment_count>
    <who name="Alexandru Damian">alexandru.damian</who>
    <bug_when>2015-03-30 12:07:33 +0000</bug_when>
    <thetext>Merged in master as 7d9dd125f1207d4b1751763d9fd33d8ed1d74498</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50380</commentid>
    <comment_count>6</comment_count>
    <who name="Mihail Stanciu">stanciux.mihail</who>
    <bug_when>2015-04-17 11:34:42 +0000</bug_when>
    <thetext>Verified on master: 33558eacc8a2d3dce3396b9ab2fd0773ac5076bc</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>