summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-08-24 16:17:54 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-24 07:53:14 +0100
commit87d3a9685dd9613e4f6718031d4ebd9344b01c47 (patch)
tree72ba52a4249d63b1e9bc91c814f2903383eb5a4a /bitbake/lib/bb
parent34ec08dc283590a25215689f41379412a6293668 (diff)
downloadpoky-87d3a9685dd9613e4f6718031d4ebd9344b01c47.tar.gz
bitbake: parse/ast: ensure saved event handlers really do get restored
In finalize() we save event handlers, register the ones relevant to the recipe being finalised, trigger events, and then restore the handlers so that one recipe's custom handlers (actually implemented within a class inherited by the recipe) do not affect other recipes. However, if an exception occurs during parsing, the saved handlers were not being restored. Use a try...finally block to ensure that the handlers are always restored. This issue became apparent since in OpenEmbedded-Core we have recently introduced a find_intercepts() handler for the bb.event.RecipePreFinalise event in image-postinst-intercepts.bbclass that images and old-style SDK recipes will end up inheriting. So far it doesn't seem that the the error has manifested itself in normal builds, but when parsing OE-Core recipes in the OE layer index it has: core-image-rt-* image recipes were parsed which in the default configuration raise SkipRecipe. The next non-image recipe that is parsed will trigger a real exception, because the find_intercepts() handler is still registered and gets fired, but in the context of the new recipe the POSTINST_INTERCEPTS_PATHS variable is not set, and the code in find_intercepts() is written with the reasonable assumption that that isn't possible given that the class itself sets a default, and thus it fails. (Bitbake rev: e5f1f8fa201774e0c3c554d59b277baa2128708f) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/parse/ast.py37
1 files changed, 19 insertions, 18 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index 6690dc51c2..9d20c323fe 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -343,30 +343,31 @@ def runAnonFuncs(d):
343 343
344def finalize(fn, d, variant = None): 344def finalize(fn, d, variant = None):
345 saved_handlers = bb.event.get_handlers().copy() 345 saved_handlers = bb.event.get_handlers().copy()
346 try:
347 for var in d.getVar('__BBHANDLERS', False) or []:
348 # try to add the handler
349 handlerfn = d.getVarFlag(var, "filename", False)
350 if not handlerfn:
351 bb.fatal("Undefined event handler function '%s'" % var)
352 handlerln = int(d.getVarFlag(var, "lineno", False))
353 bb.event.register(var, d.getVar(var, False), (d.getVarFlag(var, "eventmask") or "").split(), handlerfn, handlerln)
346 354
347 for var in d.getVar('__BBHANDLERS', False) or []: 355 bb.event.fire(bb.event.RecipePreFinalise(fn), d)
348 # try to add the handler
349 handlerfn = d.getVarFlag(var, "filename", False)
350 if not handlerfn:
351 bb.fatal("Undefined event handler function '%s'" % var)
352 handlerln = int(d.getVarFlag(var, "lineno", False))
353 bb.event.register(var, d.getVar(var, False), (d.getVarFlag(var, "eventmask") or "").split(), handlerfn, handlerln)
354
355 bb.event.fire(bb.event.RecipePreFinalise(fn), d)
356 356
357 bb.data.expandKeys(d) 357 bb.data.expandKeys(d)
358 runAnonFuncs(d) 358 runAnonFuncs(d)
359 359
360 tasklist = d.getVar('__BBTASKS', False) or [] 360 tasklist = d.getVar('__BBTASKS', False) or []
361 bb.event.fire(bb.event.RecipeTaskPreProcess(fn, list(tasklist)), d) 361 bb.event.fire(bb.event.RecipeTaskPreProcess(fn, list(tasklist)), d)
362 bb.build.add_tasks(tasklist, d) 362 bb.build.add_tasks(tasklist, d)
363 363
364 bb.parse.siggen.finalise(fn, d, variant) 364 bb.parse.siggen.finalise(fn, d, variant)
365 365
366 d.setVar('BBINCLUDED', bb.parse.get_file_depends(d)) 366 d.setVar('BBINCLUDED', bb.parse.get_file_depends(d))
367 367
368 bb.event.fire(bb.event.RecipeParsed(fn), d) 368 bb.event.fire(bb.event.RecipeParsed(fn), d)
369 bb.event.set_handlers(saved_handlers) 369 finally:
370 bb.event.set_handlers(saved_handlers)
370 371
371def _create_variants(datastores, names, function, onlyfinalise): 372def _create_variants(datastores, names, function, onlyfinalise):
372 def create_variant(name, orig_d, arg = None): 373 def create_variant(name, orig_d, arg = None):