Bug 2981 - tracebacks should be better when exception raised in anonymous python
Summary: tracebacks should be better when exception raised in anonymous python
Status: RESOLVED FIXED
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.3
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard: Patches out for review
Depends on:
Blocks:
 
Reported: 2012-08-21 14:42 UTC by Ross Burton
Modified: 2012-08-23 13:01 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Burton 2012-08-21 14:42:40 UTC
I'm chasing a bug in a piece of anonymous python in base.bbclass.

$ MACHINE=qemuppc bitbake -b ../meta/recipes-graphics/mesa/mesa-xlib_8.0.4.bb 
ERROR: Error executing a python function in <code>:
AttributeError: 'list' object has no attribute 'split'

ERROR: The stack trace of python calls that resulted in this exception/failure was:
ERROR:   File "<code>", line 2, in <module>
ERROR: 
ERROR:   File "__anon_567__home_ross_Yocto_poky_meta_classes_base_bbclass", line 51, in __anon_567__home_ross_Yocto_poky_meta_classes_base_bbclass
ERROR: 
ERROR: The code that was being executed was:
ERROR:      0001:__anon_124__home_ross_Yocto_poky_meta_classes_staging_bbclass(d)
ERROR:  *** 0002:__anon_567__home_ross_Yocto_poky_meta_classes_base_bbclass(d)
ERROR:      0003:__anon_177__home_ross_Yocto_poky_meta_classes_package_bbclass(d)
ERROR:      0004:__anon_452__home_ross_Yocto_poky_meta_classes_package_ipk_bbclass(d)
ERROR:      0005:__anon_753__home_ross_Yocto_poky_meta_classes_insane_bbclass(d)
ERROR:      0006:__anon_20__home_ross_Yocto_poky_meta_classes_debian_bbclass(d)
ERROR: (file: '<code>', lineno: 2, function: <module>)
ERROR: Command execution failed: Traceback (most recent call last):
  File "/home/ross/Yocto/poky/bitbake/lib/bb/command.py", line 87, in runAsyncCommand
    commandmethod(self.cmds_async, self, options)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/command.py", line 203, in buildFile
    command.cooker.buildFile(bfile, task)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/cooker.py", line 1053, in buildFile
    self.caches_array)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/cache.py", line 401, in parse
    datastores = cls.load_bbfile(filename, appends, configdata)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/cache.py", line 660, in load_bbfile
    bb_data = parse.handle(bbfile, bb_data)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/parse/__init__.py", line 91, in handle
    return h['handle'](fn, data, include)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/parse/parse_py/BBHandler.py", line 157, in handle
    return ast.multi_finalize(fn, d)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/parse/ast.py", line 381, in multi_finalize
    finalize(fn, d)
  File "/home/ross/Yocto/poky/bitbake/lib/bb/parse/ast.py", line 323, in finalize
    bb.utils.better_exec("\n".join(code), {"d": d}, "\n".join(code))
  File "/home/ross/Yocto/poky/bitbake/lib/bb/utils.py", line 231, in better_exec
    exec(code, _context, context)
  File "<code>", line 2, in <module>
  File "__anon_567__home_ross_Yocto_poky_meta_classes_base_bbclass", line 51, in __anon_567__home_ross_Yocto_poky_meta_classes_base_bbclass
AttributeError: 'list' object has no attribute 'split'

(I've replaced the simple_exec with better_exec)

It would be really useful if the trace included the source code of __anon_567__home_ross_Yocto_poky_meta_classes_base_bbclass().  We've obviously got it, so where is it?
Comment 1 Ross Burton 2012-08-21 15:07:22 UTC
Easy way to reproduce is to use poky 91ece5d5668ee1adb5c5e3d757426a0d5187bd84.

The exact circumstances of this bug appear to be to have a PACKAGECONFIG_append_{arch} override that doesn't apply for the current architecture, i.e. mesa-common has a _x86 override and we're building on ppc.  This results in the _append flag being in the PACKAGECONFIG var flags that are being enumerated, and this crashes later when the code assumes it has a string.
Comment 2 Richard Purdie 2012-08-22 19:08:04 UTC
Patches out for review which at least massively improve this. They're not perfect but this failure case now looks like:

ERROR: Error executing a python function in <code>:
AttributeError: 'list' object has no attribute 'split'

ERROR: The stack trace of python calls that resulted in this exception/failure was:
ERROR:   File "<code>", line 2, in <module>
ERROR: 
ERROR:   File "__anon_564__media_build1_poky_meta_classes_base_bbclass", line 48, in __anon_564__media_build1_poky_meta_classes_base_bbclass
ERROR: 
ERROR: The code that was being executed was:
ERROR:      0001:__anon_124__media_build1_poky_meta_classes_staging_bbclass(d)
ERROR:  *** 0002:__anon_564__media_build1_poky_meta_classes_base_bbclass(d)
ERROR:      0003:__anon_177__media_build1_poky_meta_classes_package_bbclass(d)
ERROR:      0004:__anon_452__media_build1_poky_meta_classes_package_ipk_bbclass(d)
ERROR:      0005:__anon_756__media_build1_poky_meta_classes_insane_bbclass(d)
ERROR:      0006:__anon_20__media_build1_poky_meta_classes_debian_bbclass(d)
ERROR: [From file: '<code>', lineno: 2, function: <module>]
ERROR:      0044:        extraconf = []
ERROR:      0045:        for flag, flagval in pkgconfigflags.items():
ERROR:      0046:            if flag == "defaultval":
ERROR:      0047:                continue
ERROR:  *** 0048:            items = flagval.split(",")
ERROR:      0049:            num = len(items)
ERROR:      0050:            if num > 4:
ERROR:      0051:                bb.error("Only enable,disable,depend,rdepend can be specified!")
ERROR:      0052:
ERROR: [From file: '__anon_564__media_build1_poky_meta_classes_base_bbclass', lineno: 48, function: __anon_564__media_build1_poky_meta_classes_base_bbclass]

The pointless stack trace at the end is now surpressed as an additional bonus.
Comment 3 Richard Purdie 2012-08-23 13:01:39 UTC
Merged in master http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=64c002875fe0a153760f174b868dc702227c00af (along with help from suddounding commits)