[OE-core] [PATCH] buildstats.bbclass: Avoid index exception in /proc/PID/io parsing

Daniel Lublin daniel at lublin.se
Fri Feb 24 10:22:20 UTC 2017


From: Pavel Modilaynen <pavelmn at axis.com>

There is some probability (depends on system load) to get empty
or line containing "0" as the last line while reading /proc/PID/io.
Avoid build failure by checking if line contains separator
":" before split.

Signed-off-by: Pavel Modilaynen <pavelmn at axis.com>
Signed-off-by: Daniel Lublin <daniel at lublin.se>
---
 meta/classes/buildstats.bbclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 8d7b5988e3..960653c704 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -31,6 +31,11 @@ def get_process_cputime(pid):
                 i = f.readline().strip()
                 if not i:
                     break
+                if not ":" in i:
+                    # one more extra line is appended (empty or containing "0")
+                    # most probably due to race condition in kernel while
+                    # updating IO stats
+                    break
                 i = i.split(": ")
                 iostats[i[0]] = i[1]
     resources = resource.getrusage(resource.RUSAGE_SELF)
-- 
2.11.1




More information about the Openembedded-core mailing list