Skip to contentSkip to conversation

event: Prevent bitbake from executing events that don't exist for multiconfig target

PATCH In review Tomasz Dziendzielski 2 participants 4 messages Feb 4, 2021 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 event: Prevent bitbake from executing events that don't exist for multiconfig target

When multiconfig is used bitbake might try to run events that don't exist for specific mc target. In cooker.py we pass self.databuilder.mcdata[mc] data that contains names of events' handlers per mc target, but fire_class_handlers uses global _handlers variable that is created during parsing of all the targets.

See [YOCTO #13071] for detailed bug information.

I added a condition to check if the handler exists for target using __BBHANDLERS variable.

--- changed the order of conditions, it should be faster than previous patch, since first condition will give False more often

---
 lib/bb/event.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/event.py +1 -1
index 694b4705..ad119bbb 100644
@@ -114,7 +114,7 @@ def fire_class_handlers(event, d):
     eid = str(event.__class__)[8:-2]
     evt_hmap = _event_handler_map.get(eid, {})
     for name, handler in list(_handlers.items()):
-        if name in _catchall_handlers or name in evt_hmap:
+        if (name in _catchall_handlers or name in evt_hmap) and name in d.getVar("__BBHANDLERS"):
             if _eventfilter:
                 if not _eventfilter(name, handler, event, d):
                     continue
Signature · 1 line
2.30.0
#1 lore raw
Quoted 28 lines · Tomasz Dziendzielski

When multiconfig is used bitbake might try to run events that don't exist for specific mc target. In cooker.py we pass self.databuilder.mcdata[mc] data that contains names of events' handlers per mc target, but fire_class_handlers uses global _handlers variable that is created during parsing of all the targets.

See [YOCTO #13071] for detailed bug information.

I added a condition to check if the handler exists for target using __BBHANDLERS variable.

--- changed the order of conditions, it should be faster than previous patch, since first condition will give False more often
---
 lib/bb/event.py | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/event.py +0 -0
index 694b4705..ad119bbb 100644
@@ -114,7 +114,7 @@ def fire_class_handlers(event, d):

     eid = str(event.__class__)[8:-2] evt_hmap = _event_handler_map.get(eid, {}) for name, handler in list(_handlers.items()):

lib/bb/event.py +1 -1
-        if name in _catchall_handlers or name in evt_hmap:
+        if (name in _catchall_handlers or name in evt_hmap) and name in d.getVar("__BBHANDLERS"):
Quoted 3 lines

             if _eventfilter:
                 if not _eventfilter(name, handler, event, d):
                     continue

This looks interesting. It does make me wonder what happens if the different multiconfigs have a handler with slightly different code but the same name though?

Cheers,

Richard

#2 lore raw
Quoted 3 lines

This looks interesting. It does make me wonder what happens if the different multiconfigs have a handler with slightly different code but the same name though?

Hi Richard,
I created two .bbclasses that add event handlers with the same name printing "default" in eventdefault.bbclass and "arm" in eventarm.bbclass. Both are triggered on BuildStarted and BuildCompleted.
If I put INHERIT += "eventdefault" to local.conf then "default" is printed 4 times (which is correct). If instead I put INHERIT += "eventarm" to multiconfig/arm.conf then "arm" is printed 2 times (also correct). But when I put INHERIT += "eventdefault" in local.conf and INHERIT+= "eventarm" in multiconfig/arm.conf then "default" is printed 4 times and "arm" is not printed at all - in this case both "default" and "arm" should be printed twice.

Best regards,
Tomasz Dziendzielski

A message that is not in the archive (sent off-list or not yet received): [email protected]