Patchwork [03/10] toaster.bbclass: fix crash on buildstats collection

login
register
mail settings
Submitter Alexandru DAMIAN
Date Dec. 18, 2013, 7:24 p.m.
Message ID <1387394687-23669-1-git-send-email-alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/63555/
State New
Headers show

Comments

Alexandru DAMIAN - Dec. 18, 2013, 7:24 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

Toaster needs buildstats to be enabled in order to
collect task statistics. The toaster.bbclass didn't
have a guard to stop task data collection if the buildstats
weren't enabled, leading to a crash.

This patch verifies that the task variables are defined before
trying to use them.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 meta/classes/toaster.bbclass | 3 +++
 1 file changed, 3 insertions(+)
Alexandru DAMIAN - Jan. 2, 2014, 9:24 a.m.
Just a heads-up, this is a stand-alone patch, not a series, despite the
subject line :(

Alex


On Wed, Dec 18, 2013 at 7:24 PM, Alex DAMIAN <alexandru.damian@intel.com>wrote:

> From: Alexandru DAMIAN <alexandru.damian@intel.com>
>
> Toaster needs buildstats to be enabled in order to
> collect task statistics. The toaster.bbclass didn't
> have a guard to stop task data collection if the buildstats
> weren't enabled, leading to a crash.
>
> This patch verifies that the task variables are defined before
> trying to use them.
>
> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
> ---
>  meta/classes/toaster.bbclass | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass
> index e1a93b5..08c7bfa 100644
> --- a/meta/classes/toaster.bbclass
> +++ b/meta/classes/toaster.bbclass
> @@ -165,6 +165,9 @@ python toaster_collect_task_stats() {
>      import bb.utils
>      import os
>
> +    if None == e.data.getVar('BUILDSTATS_BASE', True):
> +        return  # if we don't have buildstats, we cannot collect stats
> +
>      def _append_read_list(v):
>          lock = bb.utils.lockfile(e.data.expand("${TOPDIR}/toaster.lock"),
> False, True)
>
> --
> 1.8.3.2
>
>

Patch

diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass
index e1a93b5..08c7bfa 100644
--- a/meta/classes/toaster.bbclass
+++ b/meta/classes/toaster.bbclass
@@ -165,6 +165,9 @@  python toaster_collect_task_stats() {
     import bb.utils
     import os
 
+    if None == e.data.getVar('BUILDSTATS_BASE', True):
+        return  # if we don't have buildstats, we cannot collect stats
+
     def _append_read_list(v):
         lock = bb.utils.lockfile(e.data.expand("${TOPDIR}/toaster.lock"), False, True)