Bug 7398 - toaster: Infinite loop error handling issues
Summary: toaster: Infinite loop error handling issues
Status: VERIFIED FIXED
Alias: None
Product: Toaster
Classification: Build System, Metadata & Runtime
Component: toaster (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 1.8 M4
Assignee: Alexandru Damian
QA Contact: Mihail Stanciu
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-03-05 10:58 UTC by Richard Purdie
Modified: 2015-04-17 11:34 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Purdie 2015-03-05 10:58:37 UTC
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 "" > $1/installed-package-sizes.tmp
- cat $pkgcache | while read pkg pkgfile pkgarch
- do
- size=`oe-pkgdata-util -p ${PKGDATA_DIR} read-value "PKGSIZE" ${pkg}_${pkgarch}`
- if [ "$size" != "" ] ; then
- echo "$size $pkg" >> $1/installed-package-sizes.tmp
- fi
- done
- cat $1/installed-package-sizes.tmp | sort -n -r | awk '{print $1 "\tKiB " $2}' > $1/installed-package-sizes.txt
- rm $1/installed-package-sizes.tmp
+ #printf "" > $1/installed-package-sizes.tmp
+ #cat $pkgcache | while read pkg pkgfile pkgarch
+ #do
+ # size=`oe-pkgdata-util -p ${PKGDATA_DIR} read-value "PKGSIZE" ${pkg}_${pkgarch}`
+ # if [ "$size" != "" ] ; then
+ # echo "$size $pkg" >> $1/installed-package-sizes.tmp
+ # fi
+ #done
+ #cat $1/installed-package-sizes.tmp | sort -n -r | awk '{print $1 "\tKiB " $2}' > $1/installed-package-sizes.txt
+ #rm $1/installed-package-sizes.tmp

then the installed-packages-sizes.txt file isn't generated.

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

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


Keyboard Interrupt, closing down...

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

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


I'm don'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't loop infinitely.
Comment 1 Richard Purdie 2015-03-05 11:17:25 UTC
Possible fix:

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

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

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("Execution of event handler '%s' failed" % name,
                         exc_info=(etype, value, tb.tb_next))
-        raise
     except SystemExit as exc:
         if exc.code != 0:
-            logger.error("Execution of event handler '%s' failed" % name)
-        raise
+            logger.error("Execution of event handler '%s' failed (exit code %s)" % (name, exc.code))
     finally:
         del event.data
 
-- 
cgit v0.10.2
Comment 2 Alexandru Damian 2015-03-05 12:57:20 UTC
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.
Comment 3 Richard Purdie 2015-03-05 15:02:54 UTC
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.
Comment 5 Alexandru Damian 2015-03-30 12:07:33 UTC
Merged in master as 7d9dd125f1207d4b1751763d9fd33d8ed1d74498
Comment 6 Mihail Stanciu 2015-04-17 11:34:42 UTC
Verified on master: 33558eacc8a2d3dce3396b9ab2fd0773ac5076bc