Skip to contentSkip to conversation

Fixes in exception handling

PATCH New Markus Lehtonen 1 participant 3 messages Nov 1, 2016

lore
Share & tools
lore
#0 lore raw

cover Fixes in exception handling

The first patch of these fixes an obvious bug in bb.data.exported_vars(). I'm not entirely certain about the solution, though. That is, we keep ignoring exceptions, although we now print a warning if exceptions are caught. The reason I did not change the code to start raising exceptions is that I didn't want to break existing builds.

The second patch is just meant to make debugging these kind of issues easier in the future.

[YOCTO #10393]

The following changes since commit 00f79096f639ce3a9c0b7c72cfb36f14e264733d:

toaster: Update default release to Morty (2016-10-15 13:21:49 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib marquiz/bitbake/fixes-10393
http://git.openembedded.org/openembedded-core-contrib/log/?h=marquiz/bitbake/fixes-10393

Markus Lehtonen (2):
data: fix exception handling in exported_vars()
bitbake-worker: print full traceback instead of message only

 bin/bitbake-worker | 5 +++--
 lib/bb/data.py     | 8 +++++---
 2 files changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.6.6
#1 lore raw

PATCH 1/2 data: fix exception handling in exported_vars()

Fix a bug where a totally wrong value of a variable would be exported if an exception happened during d.getVar(). Also, print a warning if an exception happends instead of silently ignoring it. It would probably be best just to raise the exception, instead, but use the warning for now in order to avoid breaking existing builds.

[YOCTO #10393]

---
 lib/bb/data.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/bb/data.py +5 -3
index c1f27cd..c56965c 100644
@@ -258,11 +258,13 @@ def exported_keys(d):
                                       not d.getVarFlag(key, 'unexport', False))
 
 def exported_vars(d):
-    for key in exported_keys(d):
+    k = list(exported_keys(d))
+    for key in k:
         try:
             value = d.getVar(key, True)
-        except Exception:
-            pass
+        except Exception as err:
+            bb.warn("%s: Unable to export ${%s}: %s" % (d.getVar("FILE", True), key, err))
+            continue
 
         if value is not None:
             yield key, str(value)
Signature · 1 line
2.6.6
#2 lore raw

PATCH 2/2 bitbake-worker: print full traceback instead of message only

In reply to Markus Lehtonen

Print full traceback instead of just the exception message in the child() function inside fork_off_task(). This makes debugging a lot easier as the function catches a generic "Exception" and the exception message alone might not give much information.

[YOCTO #10393]

---
 bin/bitbake-worker | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
bin/bitbake-worker +3 -2
index 500f2ad..af66ff0 100755
@@ -11,6 +11,7 @@ import select
 import errno
 import signal
 import pickle
+import traceback
 from multiprocessing import Lock
 
 if sys.getfilesystemencoding() != "utf-8":
@@ -234,9 +235,9 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, append
                 if quieterrors:
                     the_data.setVarFlag(taskname, "quieterrors", "1")
 
-            except Exception as exc:
+            except Exception:
                 if not quieterrors:
-                    logger.critical(str(exc))
+                    logger.critical(traceback.format_exc())
                 os._exit(1)
             try:
                 if cfg.dry_run:
Signature · 1 line
2.6.6