diff mbox series

sstate: do not cache the exclude patterns in the datastore

Message ID 20261123203612.867600-1-stondo@gmail.com
State New
Headers show
Series sstate: do not cache the exclude patterns in the datastore | expand

Commit Message

Stefano Tondo Nov. 23, 2026, 8:36 p.m. UTC
From: Stefano Tondo <stefano.tondo.ext@siemens.com>

setscene_depvalid() stores the compiled patterns of
SSTATE_EXCLUDEDEPS_SYSROOT in d as _SSTATE_EXCLUDEDEPS_SYSROOT. When
bitbake calls BB_SETSCENE_DEPVALID from the runqueue, d is the cooker
datastore. Nothing removes the variable, so a memory resident server
keeps it until the configuration is parsed again.

The value is a list of tuples of compiled regular expressions. If data
tracking is enabled while setscene_depvalid() runs, the variable
history records the list. At the start of the next build, the event
log writer cannot serialize it to JSON and the build fails with:

  TypeError: Object of type Pattern is not JSON serializable

Compile the patterns in a local variable instead. They are compiled
once per call and only when the function needs them. The results of
setscene_depvalid() do not change.

Signed-off-by: Stefano Tondo <stefano.tondo.ext@siemens.com>
---
 meta/classes-global/sstate.bbclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass
index c6d9459182..c35824bc25 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -1106,7 +1106,7 @@  def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, summary=True,
         bb.parse.siggen.checkhashes(sq_data, missed, found, d)
 
     return found
-setscene_depvalid[vardepsexclude] = "SSTATE_EXCLUDEDEPS_SYSROOT _SSTATE_EXCLUDEDEPS_SYSROOT"
+setscene_depvalid[vardepsexclude] = "SSTATE_EXCLUDEDEPS_SYSROOT"
 
 BB_SETSCENE_DEPVALID = "setscene_depvalid"
 
@@ -1160,6 +1160,7 @@  def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
         return True
 
     spdx_deps = []
+    excludedeps = None
 
     for dep in taskdependees:
         logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
@@ -1187,13 +1188,12 @@  def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
             # them in.
             # See also http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146324.html
             not_needed = False
-            excludedeps = d.getVar('_SSTATE_EXCLUDEDEPS_SYSROOT')
             if excludedeps is None:
-                # Cache the regular expressions for speed
+                # Do not store the compiled expressions in d: it is the cooker
+                # datastore, which is kept across builds
                 excludedeps = []
                 for excl in (d.getVar('SSTATE_EXCLUDEDEPS_SYSROOT') or "").split():
                     excludedeps.append((re.compile(excl.split('->', 1)[0]), re.compile(excl.split('->', 1)[1])))
-                d.setVar('_SSTATE_EXCLUDEDEPS_SYSROOT', excludedeps)
             for excl in excludedeps:
                 if excl[0].match(taskdependees[dep][0]):
                     if excl[1].match(taskdependees[task][0]):