diff mbox series

bitbake-worker: preserve embedded do_ in task names

Message ID db07641b-d67e-4f87-a0cb-a704950d7c7a@wenuam.fr
State New
Headers show
Series bitbake-worker: preserve embedded do_ in task names | expand

Commit Message

WM - David KOCH Nov. 12, 2026, 1:26 p.m. UTC
Hello,

I encountered an issue in bin/bitbake-worker when executing custom tasks 
whose names contain the substring do_.

The worker currently uses:

taskname.replace("do_", "")

to populate BB_CURRENTTASK and construct the process name.

Since str.replace() removes all occurrences, this corrupts valid task 
names containing do_ internally.

For example:

do_test_pseudo_ownership

becomes:

test_pseuownership

The OE-Core sstate event handler subsequently calls 
bb.siggen.dump_this_task(), which reconstructs the task name by 
prepending do_ to BB_CURRENTTASK.

This results in an invalid task name:

do_test_pseuownership

and causes a KeyError during signature generation because that task does 
not exist in the signature generator's task dependency cache.


*Reproduction*

Define a custom task in a recipe:

fakeroot do_test_pseudo_ownership() {

echo "Testing"

}

do_test_pseudo_ownership[network] = "1"

addtask test_pseudo_ownership after do_unpack before do_configure

Then execute:

bitbake recipe-name -c test_pseudo_ownership

The task body executes, but signature generation fails with a KeyError 
referencing the corrupted task name.


*Proposed fix*

Replace unrestricted str.replace("do_", "") with removal of the leading 
task prefix only:

taskname[3:]

This preserves embedded occurrences of do_ in both BB_CURRENTTASK and 
the process name.


*Testing*

  *

    Reproduced the issue with a custom BitBake task in a Yocto build.

  *

    Verified that taskname[3:] produces the expected test_pseudo_ownership.

  *

    Verified that the patch applies cleanly to the upstream BitBake
    checkout.

The patch is based on upstream revision:

f22df7e0e00be1f3c406138b8b7269d47ea491fe

A dedicated BitBake selftest has not yet been added.


Regards.


Signed-off-by: WM - David KOCH<david.koch@wenuam.fr>
---
  bin/bitbake-worker | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

workerdata, extraconfigdata, runtask): the_data.setVar('BB_UNIHASH', 
unihash) bb.parse.siggen.setup_datacache_from_datastore(fn, the_data) - 
bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", "")))
+                bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname[3:]))
  
                  if not bb.utils.to_boolean(the_data.getVarFlag(taskname, 'network')):
                      if bb.utils.is_local_uid(uid):
-- 2.52.0.windows.1

Comments

Richard Purdie Nov. 12, 2026, 2 p.m. UTC | #1
Thanks for the report/patch! You're right this is a potential issue we
should fix.

On Thu, 2026-11-12 at 14:26 +0100, WM - David KOCH via bitbake-devel
wrote:
>  
>  
> Signed-off-by: WM - David KOCH <david.koch@wenuam.fr>
> ---
>  bin/bitbake-worker | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/bin/bitbake-worker b/bin/bitbake-worker
> index 61484a5c2..0be6f6eba 100755
> --- a/bin/bitbake-worker
> +++ b/bin/bitbake-worker
> @@ -266,7 +266,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
>                  the_data = databuilder.mcdata[mc]
>                  the_data.setVar("BB_WORKERCONTEXT", "1")
>                  the_data.setVar("BB_TASKDEPDATA", taskdepdata)
> -                the_data.setVar('BB_CURRENTTASK', taskname.replace("do_", ""))
> +                the_data.setVar('BB_CURRENTTASK', taskname[3:])
>                  if cfg.limited_deps:
>                      the_data.setVar("BB_LIMITEDDEPS", "1")
>                  the_data.setVar("BUILDNAME", workerdata["buildname"])
> @@ -285,7 +285,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
>                  the_data.setVar('BB_UNIHASH', unihash)
>                  bb.parse.siggen.setup_datacache_from_datastore(fn, the_data)
>  
> -                bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", "")))
> +                bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname[3:]))
>  
>                  if not bb.utils.to_boolean(the_data.getVarFlag(taskname, 'network')):
>                      if bb.utils.is_local_uid(uid):
> -

I think this is nearly right but it is possible the taskname might not
start with "do_". I'd therefore suggest using:

taskname.removeprefix('do_')

instead.

Thanks,

Richard
diff mbox series

Patch

diff --git a/bin/bitbake-worker b/bin/bitbake-worker
index 61484a5c2..0be6f6eba 100755
--- a/bin/bitbake-worker
+++ b/bin/bitbake-worker
@@ -266,7 +266,7 @@  def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
                  the_data = databuilder.mcdata[mc]
                  the_data.setVar("BB_WORKERCONTEXT", "1")
                  the_data.setVar("BB_TASKDEPDATA", taskdepdata)
-                the_data.setVar('BB_CURRENTTASK', taskname.replace("do_", ""))
+                the_data.setVar('BB_CURRENTTASK', taskname[3:])
                  if cfg.limited_deps:
                      the_data.setVar("BB_LIMITEDDEPS", "1")
                  the_data.setVar("BUILDNAME", workerdata["buildname"]) @@ -285,7 +285,7 @@ def fork_off_task(cfg, data, databuilder,