Patchwork [bitbake-devel] runqueue: Catch ValueError from pickle.loads

login
register
mail settings
Submitter Martin Jansa
Date Feb. 23, 2014, 10:02 a.m.
Message ID <1393149738-20871-1-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/67175/
State New
Headers show

Comments

Martin Jansa - Feb. 23, 2014, 10:02 a.m.
* exception like this keeps spinning quite quickly generating GBs of logs
  better to kill it asap and show invalid pickle

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 lib/bb/runqueue.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index 413d59f..bc48684 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -2092,14 +2092,20 @@  class runQueuePipe():
             found = False
             index = self.queue.find("</event>")
             while index != -1 and self.queue.startswith("<event>"):
-                event = pickle.loads(self.queue[7:index])
+                try:
+                    event = pickle.loads(self.queue[7:index])
+                except ValueError as e:
+                    bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[7:index]))
                 bb.event.fire_from_worker(event, self.d)
                 found = True
                 self.queue = self.queue[index+8:]
                 index = self.queue.find("</event>")
             index = self.queue.find("</exitcode>")
             while index != -1 and self.queue.startswith("<exitcode>"):
-                task, status = pickle.loads(self.queue[10:index])
+                try:
+                    task, status = pickle.loads(self.queue[10:index])
+                except ValueError as e:
+                    bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[10:index]))
                 self.rq.runqueue_process_waitpid(task, status)
                 found = True
                 self.queue = self.queue[index+11:]