Skip to contentSkip to conversation

buildstats.bbclass: Avoid index exception in /proc/PID/io parsing

PATCH In review Martin Jansa 2 participants 3 messages Jan 31, 2018 – Mar 4, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 buildstats.bbclass: Avoid index exception in /proc/PID/io parsing

From: Pavel Modilaynen <[email protected]>

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.

Backport from pyro commit b26feaf51af55f17fad79dbd53dd3ec0a37c38ff

---
 meta/classes/buildstats.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/buildstats.bbclass +5 -0
index 599a219984..415d2ee820 100644
@@ -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)
Signature · 1 line
2.15.1
#1 lore raw

ping

Quoted 39 lines · Martin Jansa

From: Pavel Modilaynen <[email protected]>

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.

Backport from pyro commit b26feaf51af55f17fad79dbd53dd3ec0a37c38ff

---
 meta/classes/buildstats.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/buildstats. renamed from meta/classes/buildstats.bbclass +0 -0

bbclass
index 599a219984..415d2ee820 100644

meta/classes/buildstats.bbclass +5 -0
@@ -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.15.1

#2 lore raw
Quoted 1 line · Martin Jansa

ping

I've queued this and the other morty patch in morty-next. Looks like we'll need to do further rounds of testing.

Cheers,

Richard