* [PATCH] bb.event: fix infinite loop on print_ui_queue
@ 2016-10-13 23:11 Aníbal Limón
2016-10-14 8:44 ` Ed Bartosh
0 siblings, 1 reply; 4+ messages in thread
From: Aníbal Limón @ 2016-10-13 23:11 UTC (permalink / raw)
To: bitbake-devel; +Cc: brian.avery, benjamin.esquivel
If bitbake ends before _uiready and bb.event.LogHandler was add
to the bitbake logger it causes an infinite loop when logging
something.
The scenario is print_ui_queue is called at exit and executes
the log handlers [2] one of them is bb.event.LogHandler this handler
appends the same entry to ui_queue causing the inifine loop [3].
In order to fix we need to keep track of events already handled to
avoid the infinite loop.
[YOCTO #10399]
[1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=10399#c0
[2] http://git.openembedded.org/bitbake/tree/lib/bb/event.py?id=41d9cd41d40b04746c82b4a940dca47df02514fc#n156
[3]
http://git.openembedded.org/bitbake/tree/lib/bb/event.py?id=41d9cd41d40b04746c82b4a940dca47df02514fc#n164
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
lib/bb/event.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/bb/event.py b/lib/bb/event.py
index c5a5f94..8464e06 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -139,7 +139,11 @@ def print_ui_queue():
# First check to see if we have any proper messages
msgprint = False
+ events_handled = []
for event in ui_queue:
+ if event in events_handled:
+ continue
+
if isinstance(event, logging.LogRecord):
if event.levelno > logging.DEBUG:
if event.levelno >= logging.WARNING:
@@ -148,14 +152,20 @@ def print_ui_queue():
logger.addHandler(stdout)
logger.handle(event)
msgprint = True
+ events_handled.append(event)
if msgprint:
return
# Nope, so just print all of the messages we have (including debug messages)
logger.addHandler(stdout)
+ events_handled = []
for event in ui_queue:
+ if event in events_handled:
+ continue
+
if isinstance(event, logging.LogRecord):
logger.handle(event)
+ events_handled.append(event)
def fire_ui_handlers(event, d):
global _thread_lock
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] bb.event: fix infinite loop on print_ui_queue
2016-10-13 23:11 [PATCH] bb.event: fix infinite loop on print_ui_queue Aníbal Limón
@ 2016-10-14 8:44 ` Ed Bartosh
2016-10-14 15:44 ` Aníbal Limón
0 siblings, 1 reply; 4+ messages in thread
From: Ed Bartosh @ 2016-10-14 8:44 UTC (permalink / raw)
To: Aníbal Limón; +Cc: benjamin.esquivel, brian.avery, bitbake-devel
On Thu, Oct 13, 2016 at 06:11:34PM -0500, Aníbal Limón wrote:
> If bitbake ends before _uiready and bb.event.LogHandler was add
> to the bitbake logger it causes an infinite loop when logging
> something.
>
> The scenario is print_ui_queue is called at exit and executes
> the log handlers [2] one of them is bb.event.LogHandler this handler
> appends the same entry to ui_queue causing the inifine loop [3].
>
> In order to fix we need to keep track of events already handled to
> avoid the infinite loop.
>
> [YOCTO #10399]
>
> [1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=10399#c0
> [2] http://git.openembedded.org/bitbake/tree/lib/bb/event.py?id=41d9cd41d40b04746c82b4a940dca47df02514fc#n156
> [3]
> http://git.openembedded.org/bitbake/tree/lib/bb/event.py?id=41d9cd41d40b04746c82b4a940dca47df02514fc#n164
>
> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
> ---
> lib/bb/event.py | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/lib/bb/event.py b/lib/bb/event.py
> index c5a5f94..8464e06 100644
> --- a/lib/bb/event.py
> +++ b/lib/bb/event.py
> @@ -139,7 +139,11 @@ def print_ui_queue():
>
> # First check to see if we have any proper messages
> msgprint = False
> + events_handled = []
> for event in ui_queue:
> + if event in events_handled:
> + continue
> +
> if isinstance(event, logging.LogRecord):
> if event.levelno > logging.DEBUG:
> if event.levelno >= logging.WARNING:
> @@ -148,14 +152,20 @@ def print_ui_queue():
> logger.addHandler(stdout)
> logger.handle(event)
> msgprint = True
> + events_handled.append(event)
> if msgprint:
> return
>
> # Nope, so just print all of the messages we have (including debug messages)
> logger.addHandler(stdout)
> + events_handled = []
> for event in ui_queue:
> + if event in events_handled:
> + continue
> +
> if isinstance(event, logging.LogRecord):
> logger.handle(event)
> + events_handled.append(event)
>
> def fire_ui_handlers(event, d):
> global _thread_lock
Would using full slice of ui_queue work the same way?
@@ -139,7 +139,7 @@ def print_ui_queue():
# First check to see if we have any proper messages
msgprint = False
- for event in ui_queue:
+ for event in ui_queue[:]:
if isinstance(event, logging.LogRecord):
if event.levelno > logging.DEBUG:
if event.levelno >= logging.WARNING:
--
Regards,
Ed
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] bb.event: fix infinite loop on print_ui_queue
2016-10-14 8:44 ` Ed Bartosh
@ 2016-10-14 15:44 ` Aníbal Limón
2016-10-15 12:30 ` Richard Purdie
0 siblings, 1 reply; 4+ messages in thread
From: Aníbal Limón @ 2016-10-14 15:44 UTC (permalink / raw)
To: ed.bartosh; +Cc: benjamin.esquivel, brian.avery, bitbake-devel
[-- Attachment #1: Type: text/plain, Size: 3013 bytes --]
On 10/14/2016 03:44 AM, Ed Bartosh wrote:
> On Thu, Oct 13, 2016 at 06:11:34PM -0500, Aníbal Limón wrote:
>> If bitbake ends before _uiready and bb.event.LogHandler was add
>> to the bitbake logger it causes an infinite loop when logging
>> something.
>>
>> The scenario is print_ui_queue is called at exit and executes
>> the log handlers [2] one of them is bb.event.LogHandler this handler
>> appends the same entry to ui_queue causing the inifine loop [3].
>>
>> In order to fix we need to keep track of events already handled to
>> avoid the infinite loop.
>>
>> [YOCTO #10399]
>>
>> [1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=10399#c0
>> [2] http://git.openembedded.org/bitbake/tree/lib/bb/event.py?id=41d9cd41d40b04746c82b4a940dca47df02514fc#n156
>> [3]
>> http://git.openembedded.org/bitbake/tree/lib/bb/event.py?id=41d9cd41d40b04746c82b4a940dca47df02514fc#n164
>>
>> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
>> ---
>> lib/bb/event.py | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/lib/bb/event.py b/lib/bb/event.py
>> index c5a5f94..8464e06 100644
>> --- a/lib/bb/event.py
>> +++ b/lib/bb/event.py
>> @@ -139,7 +139,11 @@ def print_ui_queue():
>>
>> # First check to see if we have any proper messages
>> msgprint = False
>> + events_handled = []
>> for event in ui_queue:
>> + if event in events_handled:
>> + continue
>> +
>> if isinstance(event, logging.LogRecord):
>> if event.levelno > logging.DEBUG:
>> if event.levelno >= logging.WARNING:
>> @@ -148,14 +152,20 @@ def print_ui_queue():
>> logger.addHandler(stdout)
>> logger.handle(event)
>> msgprint = True
>> + events_handled.append(event)
>> if msgprint:
>> return
>>
>> # Nope, so just print all of the messages we have (including debug messages)
>> logger.addHandler(stdout)
>> + events_handled = []
>> for event in ui_queue:
>> + if event in events_handled:
>> + continue
>> +
>> if isinstance(event, logging.LogRecord):
>> logger.handle(event)
>> + events_handled.append(event)
>>
>> def fire_ui_handlers(event, d):
>> global _thread_lock
>
> Would using full slice of ui_queue work the same way?
Yes it will work and is more simple, i'll send v2.
alimon
>
> @@ -139,7 +139,7 @@ def print_ui_queue():
>
> # First check to see if we have any proper messages
> msgprint = False
> - for event in ui_queue:
> + for event in ui_queue[:]:
> if isinstance(event, logging.LogRecord):
> if event.levelno > logging.DEBUG:
> if event.levelno >= logging.WARNING:
>
>
> --
> Regards,
> Ed
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bb.event: fix infinite loop on print_ui_queue
2016-10-14 15:44 ` Aníbal Limón
@ 2016-10-15 12:30 ` Richard Purdie
0 siblings, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2016-10-15 12:30 UTC (permalink / raw)
To: Aníbal Limón, ed.bartosh
Cc: bitbake-devel, brian.avery, benjamin.esquivel
On Fri, 2016-10-14 at 10:44 -0500, Aníbal Limón wrote:
> On 10/14/2016 03:44 AM, Ed Bartosh wrote:
> > On Thu, Oct 13, 2016 at 06:11:34PM -0500, Aníbal Limón wrote:
> > > Would using full slice of ui_queue work the same way?
> Yes it will work and is more simple, i'll send v2.
Much nicer, thanks!
Cheers,
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-15 12:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-13 23:11 [PATCH] bb.event: fix infinite loop on print_ui_queue Aníbal Limón
2016-10-14 8:44 ` Ed Bartosh
2016-10-14 15:44 ` Aníbal Limón
2016-10-15 12:30 ` Richard Purdie
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.