From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a1-smtp.messagingengine.com (fhigh-a1-smtp.messagingengine.com [103.168.172.152]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.19392.1795985546026840631 for ; Sun, 29 Nov 2026 12:52:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@pbarker.dev header.s=fm2 header.b=Ro8NNydU; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=dq8sxh5e; spf=pass (domain: pbarker.dev, ip: 103.168.172.152, mailfrom: paul@pbarker.dev) Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 277A41400234 for ; Sun, 29 Nov 2026 15:52:25 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Sun, 29 Nov 2026 15:52:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pbarker.dev; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1795985545; x=1796071945; bh=Z4J/Yz/RKLky1NAKfbCZuNYIG7Xj5RRT072l3yA/IK0=; b= Ro8NNydUWPUsHHVw2QTI66Pu5fhmnDBiZKppraqrDSu6pCkqEYAx59JLbIWau6xe 5tZMHKPMPUOiB9JFVUy/FUt1sIpz6TdlcRs0aslfrPhBFlAgl8rn6/soOHf3uqvL DmgppG/4Vso08ycN44TLAxj8orgMc08xxgMhPnTJyOCOWgfga6qZnyt46Glu6XQi 1cUxy7GuP5cNwRTKCuM7KRDPjMQcxcH8C/eLjaVr74SPNphtu+LYNu1hvUIkpDJg ckbfIXX9j4zCURaYSgLnzi9k8E1E7vK9DpC2te9pfLQ8j3bQULV7UkcLReDyVSot 7nHDEWtEmrQmg/sW802ziA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1795985545; x=1796071945; bh=Z 4J/Yz/RKLky1NAKfbCZuNYIG7Xj5RRT072l3yA/IK0=; b=dq8sxh5eIumjsLovz T8/uR55xPUi3319nQf7p73mrcEVTG/TneLOshnb4z3/63d7OOaetbSo0MJDRwQzt DUH63MxTxPl09njNs3goyk0yHDhkMFMn5ywO2emnWWLQF2Aglsw7ylxqxoHxuRg0 YUBoZJcHtai0jrRyc50a5eBv+1GdwH3/NhVKx9UGfy7Bl2HuzzYjnm+dQlhLWwu4 tTdhX5wW26Zawzp4RLPnzZDL5WxXQ8i/HJAydL0OZ6iSa8Fl+rq3b1rfB9OYoWdH kpG12nYTlp1C4JpvJHmhncLkqD9H1BMYc0pUqq53MOjVcQuk6q4KS3E1f2oUFLaz rWtmw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pbarker.dev a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795985545; d=pbarker.dev; mf=PHBhdWxAcGJhcmtlci5kZXY+; rt=PGJpdGJha2UtZGV2ZWxAbGlzdHMub3BlbmVtYmVkZGVkLm9yZz4=; s=fm2:rsa-sha256:Zf5iY0dHRw5kcTt8sstYWR7NGix9rQgUoMTorQxEpcwY6ja xX7METLZz8hjG6BBIPMV13bOG4g1lrdyHOtYlm2kkanB2EgIGT7jGqbegdrDTL1s 7jEs1Jf8Xr7h5XcULbj0iKghRvN/S/SaZ89G2wlH1ays4UoY1grY+ATtkzs0Ugh7 KlNNIJPenZJu1osdU3IqiE+C8xnB9tVev5QJx/04eXYRf+RbVWbruy3yQtKGqiYD RqVJr4VHx4DpPM2S+CIxnWYzc4of5fkveStRReUd8+rks5ql1/7kJ3d4XmrUquI2 +uiUHZRXQ8+z7+p+nzY6P+8Smw824nX6FUDsDWQ==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=11; hn=content-transfer-encoding,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:PjEZebsFrnguRyK4SnSXBDG6wueaDb66eSFtm4T0ooE=:E/WRTIRN461GpRyT3LM9Q/24WMod15Dl5SVHQnjf/90=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGCx+jbRm4wMcUBPuy8LaG21PhS7g/ZDCawcNeFbb28lpAco/YIBoaYCAiKtnIPEa Qi7geLo0CayYtHfoeZ8nIN2cRDPdiDKnQYmL0KyfFCBrvl7Te9kadeBhmMgBT6bDxIq/5I m/p3QeC+HjfuAWB4WaGl5MyQ1Z7rCGHtRD9u1hJ6LAAvBd8n4xn8ZzpQDXWzEPAfkwWnbu J+zrItSFTxRKwoGU4Zhpm6t60DGnVUhEvT4pYgS/r9QnFCQxF2T/vURY7ocfmVUsWT8zwq chTrmQy/82VqveG42Q683rzHvKjV4K18B5bJa28C9d6UT16Ts0dYQXsclTAlKIxrhIiHmM wlC8izNA1KUG+2SKyYJComzApCoT0P6jS1lmyJAizvpLTpGZOSVK4iaWXwnoRO9TwCibE/ I/XF2akh7ZdRVOvpQHBtgHdH0bIi4gVjETaMtiHsnSB5voFtxeZXIZC2A28RGQ/kx6FppS S+Ba9/EneKCcD7ii+W0fy/E42BFIVzJMo63YjYxy8Aebu05XVkVeDvHkZaEUi7gTlzpRtK 6700fATT9eIiGLa798XZJx38NyFPoYaM8UC/LuTIv6XfhkwJv2SZdpf1sipb3ouvUhg4xK /Tdy5EejqhJ2gdsN08uPHAiriM1SBNzx+ryUB8uF9f8RG+UC9/NRz5toc7NA X-ME-Proxy: Feedback-ID: i51494658:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Nov 2026 15:52:24 -0500 (EST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 29 Nov 2026 20:52:23 +0000 Message-Id: To: "Ricardo Salveti" , Subject: Re: [PATCH] fetch: Don't reuse the url data cached for a freed datastore From: "Paul Barker" X-Mailer: aerc 0.22.0 References: <20261128220333.3995114-1-ricardo.salveti@oss.qualcomm.com> In-Reply-To: <20261128220333.3995114-1-ricardo.salveti@oss.qualcomm.com> List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Sun, 29 Nov 2026 20:52:34 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/20486 On Sat Nov 28, 2026 at 10:03 PM GMT, Ricardo Salveti wrote: > The url data cache is keyed by the recipe file and id(d), and an entry > stays after its datastore is freed. Python reuses the id of a freed > object, so a new datastore of the same recipe can get the freed one's > url data: its urls on top of the new ones, or silently its SRCREV. > > meta-qcom's oe-selftest has been flaky since oe-core 4746cd7138bc > ("oeqa/utils/commands: use tinfoil in get_bb_vars"): back-to-back > tinfoil sessions reuse one server, each parses a recipe in it, and the > parsers forked later inherit its cache. A recipe whose BBCLASSEXTEND > variants use different git urls then sometimes fails to parse: > > The SRCREV_FORMAT variable must be set when multiple SCMs are used. > The SCMs are: > git://github.com/qualcomm-linux/kernel.git;nobranch=3D1;protocol=3Dhttp= s > git://github.com/qualcomm-linux/kernel.git;branch=3Dqcom-next;protocol= =3Dhttps > > Keep a weak reference to the datastore with each entry and only use the > entry for that datastore. Dead entries stay in the cache, as before. > > A new test gives two datastores the same id and fails without this. > > Fixes: 9a5dd1be6339 ("fetch2: Fix urldata_cache key issues") > AI-Generated: Uses Claude Code (Claude Fable 5.2) > Signed-off-by: Ricardo Salveti > --- > lib/bb/fetch/__init__.py | 9 +++++++-- > lib/bb/tests/fetch.py | 23 +++++++++++++++++++++++ > 2 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py > index 612336170..76e0778d1 100644 > --- a/lib/bb/fetch/__init__.py > +++ b/lib/bb/fetch/__init__.py > @@ -24,6 +24,7 @@ import subprocess > import pickle > import errno > import shlex > +import weakref > import bb.utils > import bb.checksum > import bb.process > @@ -1863,7 +1864,11 @@ class Fetch(object): > if cache and fn: > key =3D mc + fn + str(id(d)) > if key in urldata_cache: > - self.ud =3D urldata_cache[key] > + # id() values get reused once a datastore is freed, so check= the > + # entry was stored for this datastore > + cached_d, cached_ud =3D urldata_cache[key] > + if cached_d() is d: > + self.ud =3D cached_ud > =20 > # the unpack_tracer object needs to be made available to possibl= e nested > # Fetch instances (when those are created by gitsm and npmsw fet= chers) > @@ -1895,7 +1900,7 @@ class Fetch(object): > pass > =20 > if key: > - urldata_cache[key] =3D self.ud > + urldata_cache[key] =3D (weakref.ref(d), self.ud) Hi Ricardo, This and the above is basically the same fix I have locally after some experimentation with Claude to try to fix bugs #15848 & #16382. This alone isn't a complete fix for both of those, but it looks right and it's one step closer to the fix. I can follow up with other patches. > =20 > def localpath(self, url): > if url not in self.urls: > diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py > index 104ee1f68..23ec5ddc1 100644 > --- a/lib/bb/tests/fetch.py > +++ b/lib/bb/tests/fetch.py > @@ -454,6 +454,29 @@ class FetcherTest(unittest.TestCase): > except bb.process.ExecutionError: > self.git(['config', 'user.name', 'Your Name'], cwd=3Dcwd) > =20 > +class UrldataCacheTest(FetcherTest): > + def recipe(self, branch): > + d =3D self.d.createCopy() > + d.setVar("FILE", "/recipes/foo_git.bb") > + d.setVar("SRCREV", "82ea737a0b42a8b53e11c9cde141e9e9c0bd8c40") > + d.setVar("SRC_URI", "git://git.openembedded.org/bitbake;%s;proto= col=3Dhttps" % branch) > + return d > + > + def test_same_datastore(self): > + d =3D self.recipe("branch=3Dmaster") > + self.assertIs(bb.fetch.Fetch([], d).ud, bb.fetch.Fetch([], d).ud= ) > + > + def test_reused_datastore_id(self): > + # The cache key uses id(d) and Python reuses the id of a freed o= bject, > + # so give two datastores of one recipe the same id > + with unittest.mock.patch.object(bb.fetch, "id", create=3DTrue, r= eturn_value=3D0) as fake_id: > + d1 =3D self.recipe("nobranch=3D1") > + bb.fetch.Fetch([], d1) > + d2 =3D self.recipe("branch=3Dmaster") > + fetcher =3D bb.fetch.Fetch([], d2) > + self.assertTrue(fake_id.called) > + self.assertEqual(list(fetcher.ud), d2.getVar("SRC_URI").split()) This is better than the test case I have which messes around triggering garbage collection, nice! Best regards, --=20 Paul Barker