Go to file
Richard Purdie 83fda1bb2e bitbake: event/utils: Avoid deadlock from lock_timeout() and recursive events
We've been seeing intermittent failures on Ubuntu 22.04 in oe-selftest which
were problematic to debug. The failure was inside lock_timeout and once that was
identified and the backtrace obtained, the problem becomes clearer:

  File "X/bitbake/lib/bb/server/process.py", line 466, in idle_thread_internal
    retval = function(self, data, False)
  File "X/bitbake/lib/bb/command.py", line 123, in runAsyncCommand
    self.cooker.updateCache()
  File "X/bitbake/lib/bb/cooker.py", line 1629, in updateCache
    self.parser = CookerParser(self, mcfilelist, total_masked)
  File "X/bitbake/lib/bb/cooker.py", line 2141, in __init__
    self.bb_caches = bb.cache.MulticonfigCache(self.cfgbuilder, self.cfghash, cooker.caches_array)
  File "X/bitbake/lib/bb/cache.py", line 772, in __init__
    loaded += c.prepare_cache(progress)
  File "X/bitbake/lib/bb/cache.py", line 435, in prepare_cache
    loaded = self.load_cachefile(progress)
  File "X/bitbake/lib/bb/cache.py", line 516, in load_cachefile
    progress(cachefile.tell() + previous_progress)
  File "X/bitbake/lib/bb/cache.py", line 751, in progress
    bb.event.fire(bb.event.CacheLoadProgress(current_progress, cachesize),
  File "X/bitbake/lib/bb/event.py", line 234, in fire
    fire_ui_handlers(event, d)
  File "X/bitbake/lib/bb/event.py", line 210, in fire_ui_handlers
    _ui_handlers[h].event.send(event)
  File "X/bitbake/lib/bb/cooker.py", line 117, in send
    str_event = codecs.encode(pickle.dumps(event), \'base64\').decode(\'utf-8\')
  File "/usr/lib/python3.10/asyncio/sslproto.py", line 320, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
  File "/usr/lib/python3.10/warnings.py", line 109, in _showwarnmsg
    sw(msg.message, msg.category, msg.filename, msg.lineno,
  File "X/bitbake/lib/bb/main.py", line 113, in _showwarning
    warnlog.warning(s)
  File "/usr/lib/python3.10/logging/__init__.py", line 1489, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python3.10/logging/__init__.py", line 1624, in _log
    self.handle(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 1634, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 1696, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 968, in handle
    self.emit(record)
  File "X/bitbake/lib/bb/event.py", line 778, in emit
    fire(record, None)
  File "X/bitbake/lib/bb/event.py", line 234, in fire
    fire_ui_handlers(event, d)
  File "X/bitbake/lib/bb/event.py", line 197, in fire_ui_handlers
    with bb.utils.lock_timeout(_thread_lock):
  File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "X/bitbake/lib/bb/utils.py", line 1888, in lock_timeout
    bb.server.process.serverlog("Couldn\'t get the lock for 5 mins, timed out, exiting. %s" % traceback.format_stack())

or put in simpler terms, whilst sending an event(), an unrelated warning
message happens to be triggered from asyncio:

/usr/lib/python3.10/asyncio/sslproto.py:320: ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x7f0e797d3100>

which triggers a second event() which can't be sent as we're already
in the critcal section and already hold the lock.

That warning is due to the version of asyncio used on Ubuntu 22.04 with
python 3.10 and that comined with timing issues explains why we don't
see it on other python versions or distros.

We can't handle the second event as the lock is there to serialise the
events. Instead, we queue the event and then process the queue later.

Add a new version of lock_timeout which allows us to handle the situation
more gracefully.

(Bitbake rev: 696c2c1ef095f8b11c7d2eff36fae50f58c62e5e)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 2c590ff1aff89d23b25ce808650f200013a1e6af)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
2025-03-15 06:40:07 -07:00
bitbake bitbake: event/utils: Avoid deadlock from lock_timeout() and recursive events 2025-03-15 06:40:07 -07:00
contrib contrib/git-hooks: add a sendemail-validate example hook that adds FROM: lines to outgoing patch emails 2020-12-30 14:01:07 +00:00
documentation ref-manual: remove OE_IMPORTS 2025-03-08 06:22:57 -08:00
meta build-appliance-image: Update to scarthgap head revision 2025-03-10 12:34:01 -07:00
meta-poky poky.conf: bump version for 5.0.8 2025-03-10 12:32:02 -07:00
meta-selftest selftest-hardlink: Add additional test cases 2024-08-06 19:11:18 -07:00
meta-skeleton linux-yocto-custom: Fix comment override syntax 2024-07-03 06:28:36 -07:00
meta-yocto-bsp yocto-bsp/genericarm64: add virtio-gpu 2024-04-08 23:33:53 +01:00
scripts scripts/install-buildtools: Update to 5.0.7 2025-02-21 06:25:06 -08:00
.gitignore vscode: drop .vscode folder 2024-02-19 11:34:33 +00:00
.templateconf meta-poky/conf: move default templates to conf/templates/default/ 2022-09-01 10:07:02 +01:00
LICENSE meta/lib+scripts: Convert to SPDX license headers 2019-05-09 16:31:55 +01:00
LICENSE.GPL-2.0-only meta/lib+scripts: Convert to SPDX license headers 2019-05-09 16:31:55 +01:00
LICENSE.MIT meta/lib+scripts: Convert to SPDX license headers 2019-05-09 16:31:55 +01:00
MAINTAINERS.md MAINTAINERS.md: no more need for a prelink-cross maintainer 2022-05-07 22:31:21 +01:00
MEMORIAM MEMORIAM: Add recognition for contributors no longer with us 2020-01-30 15:22:35 +00:00
oe-init-build-env oe-init-build-env: generate .vscode from template 2024-02-19 11:34:33 +00:00
README.hardware.md README: Move to using markdown as the format 2021-06-16 16:33:18 +01:00
README.md Add README link to README.poky 2021-07-19 18:07:21 +01:00
README.OE-Core.md README: fix mail address in git example command 2023-09-04 10:27:46 +01:00
README.poky.md README: Move to using markdown as the format 2021-06-16 16:33:18 +01:00
README.qemu.md README.OE-Core/README.qemu: Move to markdown format 2021-07-20 08:51:06 +01:00
SECURITY.md SECURITY.md: add file 2023-10-19 11:31:13 +01:00

Poky

Poky is an integration of various components to form a pre-packaged build system and development environment which is used as a development and validation tool by the Yocto Project. It features support for building customised embedded style device images and custom containers. There are reference demo images ranging from X11/GTK+ to Weston, commandline and more. The system supports cross-architecture application development using QEMU emulation and a standalone toolchain and SDK suitable for IDE integration.

Additional information on the specifics of hardware that Poky supports is available in README.hardware. Further hardware support can easily be added in the form of BSP layers which extend the systems capabilities in a modular way. Many layers are available and can be found through the layer index.

As an integration layer Poky consists of several upstream projects such as BitBake, OpenEmbedded-Core, Yocto documentation, the 'meta-yocto' layer which has configuration and hardware support components. These components are all part of the Yocto Project and OpenEmbedded ecosystems.

The Yocto Project has extensive documentation about the system including a reference manual which can be found at https://docs.yoctoproject.org/

OpenEmbedded is the build architecture used by Poky and the Yocto project. For information about OpenEmbedded, see the OpenEmbedded website.

Contribution Guidelines

Please refer to our contributor guide here: https://docs.yoctoproject.org/dev/contributor-guide/ for full details on how to submit changes.

Where to Send Patches

As Poky is an integration repository (built using a tool called combo-layer), patches against the various components should be sent to their respective upstreams:

OpenEmbedded-Core (files in meta/, meta-selftest/, meta-skeleton/, scripts/):

BitBake (files in bitbake/):

Documentation (files in documentation/):

meta-yocto (files in meta-poky/, meta-yocto-bsp/):

If in doubt, check the openembedded-core git repository for the content you intend to modify as most files are from there unless clearly one of the above categories. Before sending, be sure the patches apply cleanly to the current git repository branch in question.

CII Best Practices