All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] event: Prevent bitbake from executing events that don't exist for multiconfig target
@ 2021-02-04  1:02 Tomasz Dziendzielski
  2021-02-04  9:25 ` [bitbake-devel] " Richard Purdie
  0 siblings, 1 reply; 4+ messages in thread
From: Tomasz Dziendzielski @ 2021-02-04  1:02 UTC (permalink / raw)
  To: bitbake-devel; +Cc: 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.

Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>

--- 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(-)

diff --git a/lib/bb/event.py b/lib/bb/event.py
index 694b4705..ad119bbb 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -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
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [bitbake-devel] [PATCH v2] event: Prevent bitbake from executing events that don't exist for multiconfig target
  2021-02-04  1:02 [PATCH v2] event: Prevent bitbake from executing events that don't exist for multiconfig target Tomasz Dziendzielski
@ 2021-02-04  9:25 ` Richard Purdie
  2021-02-04 16:14   ` Tomasz Dziendzielski
       [not found]   ` <1660975EC3653C7D.8308@lists.openembedded.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Purdie @ 2021-02-04  9:25 UTC (permalink / raw)
  To: Tomasz Dziendzielski, bitbake-devel

On Thu, 2021-02-04 at 02:02 +0100, Tomasz Dziendzielski wrote:
> 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.
> 
> Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
> 
> --- 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(-)
> 
> diff --git a/lib/bb/event.py b/lib/bb/event.py
> index 694b4705..ad119bbb 100644
> --- a/lib/bb/event.py
> +++ b/lib/bb/event.py
> @@ -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

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bitbake-devel] [PATCH v2] event: Prevent bitbake from executing events that don't exist for multiconfig target
  2021-02-04  9:25 ` [bitbake-devel] " Richard Purdie
@ 2021-02-04 16:14   ` Tomasz Dziendzielski
       [not found]   ` <1660975EC3653C7D.8308@lists.openembedded.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Tomasz Dziendzielski @ 2021-02-04 16:14 UTC (permalink / raw)
  To: Richard Purdie; +Cc: bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

> 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

[-- Attachment #2: Type: text/html, Size: 1090 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bitbake-devel] [PATCH v2] event: Prevent bitbake from executing events that don't exist for multiconfig target
       [not found]   ` <1660975EC3653C7D.8308@lists.openembedded.org>
@ 2021-02-04 22:18     ` Tomasz Dziendzielski
  0 siblings, 0 replies; 4+ messages in thread
From: Tomasz Dziendzielski @ 2021-02-04 22:18 UTC (permalink / raw)
  To: Tomasz Dziendzielski; +Cc: Richard Purdie, bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

I submitted a new patch with different subject (because it's content is
different). Please check:
https://lists.openembedded.org/g/bitbake-devel/message/11965

Best regards,
Tomasz Dziendzielski

[-- Attachment #2: Type: text/html, Size: 354 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-04 22:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04  1:02 [PATCH v2] event: Prevent bitbake from executing events that don't exist for multiconfig target Tomasz Dziendzielski
2021-02-04  9:25 ` [bitbake-devel] " Richard Purdie
2021-02-04 16:14   ` Tomasz Dziendzielski
     [not found]   ` <1660975EC3653C7D.8308@lists.openembedded.org>
2021-02-04 22:18     ` Tomasz Dziendzielski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.