mbox series

[0/1] base.bbclass: Fix the recipe parsing race issue

Message ID 20250814172348.3882586-1-tony.rex@ericsson.com
Headers show
Series base.bbclass: Fix the recipe parsing race issue | expand

Message

Tony Rex Aug. 14, 2025, 5:23 p.m. UTC
It seems that the race condition happens when doing do_fetch on really small repos
and it can be difficult to reproduce so below the other case with floating tag/branch
that is easier to verify.

To verify the floating tag/branch issue have s simple recipe hello_1.0.bb and set the SRC_URI to
SRC_URI = "git://<repository>;protocol=https;user=${USER};branch=master;tag=v1.0"

run command bitbake hello everything builds.
 
Apply the patch

run command bitbake hello
ERROR: hello-1.0-r1 do_fetch: Bitbake Fetcher Error: FetchError("Recipe uses a floating tag/branch 'v1.0' for repo '<repository>' without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)
ERROR: Logfile of failure stored in: hello/1.0/temp/log.do_fetch.3289932
ERROR: Task (hello/hello_1.0.bb:do_fetch) failed with exit code '1'

Tony Rex (1):
  base.bbclass: Fix the recipe parsing race issue

 meta/classes-global/base.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mathieu Dubois-Briand Aug. 15, 2025, 9:25 a.m. UTC | #1
On Thu Aug 14, 2025 at 7:23 PM CEST, Tony Rex via lists.openembedded.org wrote:
> It seems that the race condition happens when doing do_fetch on really small repos
> and it can be difficult to reproduce so below the other case with floating tag/branch
> that is easier to verify.
>
> To verify the floating tag/branch issue have s simple recipe hello_1.0.bb and set the SRC_URI to
> SRC_URI = "git://<repository>;protocol=https;user=${USER};branch=master;tag=v1.0"
>
> run command bitbake hello everything builds.
>  
> Apply the patch
>
> run command bitbake hello
> ERROR: hello-1.0-r1 do_fetch: Bitbake Fetcher Error: FetchError("Recipe uses a floating tag/branch 'v1.0' for repo '<repository>' without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)
> ERROR: Logfile of failure stored in: hello/1.0/temp/log.do_fetch.3289932
> ERROR: Task (hello/hello_1.0.bb:do_fetch) failed with exit code '1'
>
> Tony Rex (1):
>   base.bbclass: Fix the recipe parsing race issue
>
>  meta/classes-global/base.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Hi Tony,

Thanks for your patch.

It looks like this is breaking some builds with the following error:

oeqa.utils.subprocesstweak.OETestCalledProcessError: Command '. /srv/pokybuild/yocto-worker/qemux86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0/testsdkext/environment-setup-core2-64-poky-linux > /dev/null; devtool add kernel-module-hello-world https://git.yoctoproject.org/git/kernel-module-hello-world;' returned non-zero exit status 1.
...
ERROR: Bitbake Fetcher Error: FetchError("Recipe uses a floating tag/branch 'master' for repo 'git.yoctoproject.org/git/kernel-module-hello-world' without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)

https://autobuilder.yoctoproject.org/valkyrie/#/builders/68/builds/2284
https://autobuilder.yoctoproject.org/valkyrie/#/builders/30/builds/2199
https://autobuilder.yoctoproject.org/valkyrie/#/builders/16/builds/2247

Can you have a look at this error please?

Best regards,
Mathieu
Tony Rex Aug. 15, 2025, 3:16 p.m. UTC | #2
Hi Mathieu!

I think that this is how it is intended to work, bitbake does not allow floating tag/branch anymore.
Please correct me if I'm wrong @Richard Purdie (who implemented this for security reasons I think.)

The patch that I have makes sure that the parsing and setting of the variables in the recipe are done before executing the do_fetch command,
and as a side effect the floating tag/branch protection is working as intended again.

How does the recipe look like?
devtool add kernel-module-hello-world https://git.yoctoproject.org/git/kernel-module-hello-world
The one I get looks like this:

cat build/workspace/recipes/kernel-module-hello-world/kernel-module-hello-world_git.bb
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)

# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
#
# The following license files were not able to be identified and are
# represented as "Unknown" below, you will need to check them yourself:
#   LICENSE
LICENSE = "Unknown"
LIC_FILES_CHKSUM = "file://LICENSE;md5=7b785be6433a2e4af6a641cc7f0330d1"

SRC_URI = "git://git.yoctoproject.org/git/kernel-module-hello-world;protocol=https;branch=master"

# Modify these as desired
PV = "1.0+git"
SRCREV = "b66f0f2bd559a1df81fc1bda240eba07a2ecdd2b"

S = "${WORKDIR}/git"

inherit module

EXTRA_OEMAKE:append:task-install = " -C ${STAGING_KERNEL_DIR} M=${S}"
EXTRA_OEMAKE += "KERNEL_DIR=${STAGING_KERNEL_DIR}"

And it contains SRCREV = "b66f0f2bd559a1df81fc1bda240eba07a2ecdd2b"

Tony

-----Original Message-----
From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Sent: Friday, 15 August 2025 11:26
To: Tony Rex <tony.rex@ericsson.com>; openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH 0/1] base.bbclass: Fix the recipe parsing race issue

[You don't often get email from mathieu.dubois-briand@bootlin.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On Thu Aug 14, 2025 at 7:23 PM CEST, Tony Rex via lists.openembedded.org wrote:
> It seems that the race condition happens when doing do_fetch on really
> small repos and it can be difficult to reproduce so below the other
> case with floating tag/branch that is easier to verify.
>
> To verify the floating tag/branch issue have s simple recipe
> hello_1.0.bb and set the SRC_URI to SRC_URI = "git://<repository>;protocol=https;user=${USER};branch=master;tag=v1.0"
>
> run command bitbake hello everything builds.
>
> Apply the patch
>
> run command bitbake hello
> ERROR: hello-1.0-r1 do_fetch: Bitbake Fetcher Error:
> FetchError("Recipe uses a floating tag/branch 'v1.0' for repo
> '<repository>' without a fixed SRCREV yet doesn't call
> bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)
> ERROR: Logfile of failure stored in:
> hello/1.0/temp/log.do_fetch.3289932
> ERROR: Task (hello/hello_1.0.bb:do_fetch) failed with exit code '1'
>
> Tony Rex (1):
>   base.bbclass: Fix the recipe parsing race issue
>
>  meta/classes-global/base.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Hi Tony,

Thanks for your patch.

It looks like this is breaking some builds with the following error:

oeqa.utils.subprocesstweak.OETestCalledProcessError: Command '. /srv/pokybuild/yocto-worker/qemux86-64/build/build/tmp/work/qemux86_64-poky-linux/core-image-sato/1.0/testsdkext/environment-setup-core2-64-poky-linux > /dev/null; devtool add kernel-module-hello-world https://git.yoctoproject.org/git/kernel-module-hello-world;' returned non-zero exit status 1.
...
ERROR: Bitbake Fetcher Error: FetchError("Recipe uses a floating tag/branch 'master' for repo 'git.yoctoproject.org/git/kernel-module-hello-world' without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)

https://autobuilder.yoctoproject.org/valkyrie/#/builders/68/builds/2284
https://autobuilder.yoctoproject.org/valkyrie/#/builders/30/builds/2199
https://autobuilder.yoctoproject.org/valkyrie/#/builders/16/builds/2247

Can you have a look at this error please?

Best regards,
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com/