summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-27 13:04:32 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-02 16:11:40 +0100
commitb020384e8534defcc3bc801ddeef67fd7980a389 (patch)
tree009e92d2f9e9773c0f7b918c1b39bc322ef4d311
parentcbe8754af238665e1e3b27bb14bcb7062f0fddc2 (diff)
downloadpoky-b020384e8534defcc3bc801ddeef67fd7980a389.tar.gz
bitbake: runqueue: Avoid unpickle errors in rare cases
In rare cases the pickled data from a task contains "</event>" which causes backtrace. This can be reproduced with something like: do_unpack_prepend () { bb.warn("</event>") } There are several solutions but the easiest is to catch this exception and look for the next marker instead as this should be the only way such an unpickle error could occur. This fixes rare exceptions seen on the autobuilder. Also add in other potential exceptions listed in the pickle manual page so that better debug is obtained should there be an error in this code path in future. exitcode doesn't need the same handling since we control what is in that data field and it could never contain </exitcode> (Bitbake rev: 6d780fe3a111adbf3f3d2dda22d5a0787b195b62) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 5ada512d6f9cbbdf1172ff7818117c38b12225ca) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/runqueue.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 16f076f3b1..30cab5379e 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -2958,7 +2958,12 @@ class runQueuePipe():
2958 while index != -1 and self.queue.startswith(b"<event>"): 2958 while index != -1 and self.queue.startswith(b"<event>"):
2959 try: 2959 try:
2960 event = pickle.loads(self.queue[7:index]) 2960 event = pickle.loads(self.queue[7:index])
2961 except ValueError as e: 2961 except (ValueError, pickle.UnpicklingError, AttributeError, IndexError) as e:
2962 if isinstance(e, pickle.UnpicklingError) and "truncated" in str(e):
2963 # The pickled data could contain "</event>" so search for the next occurance
2964 # unpickling again, this should be the only way an unpickle error could occur
2965 index = self.queue.find(b"</event>", index + 1)
2966 continue
2962 bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[7:index])) 2967 bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[7:index]))
2963 bb.event.fire_from_worker(event, self.d) 2968 bb.event.fire_from_worker(event, self.d)
2964 if isinstance(event, taskUniHashUpdate): 2969 if isinstance(event, taskUniHashUpdate):
@@ -2970,7 +2975,7 @@ class runQueuePipe():
2970 while index != -1 and self.queue.startswith(b"<exitcode>"): 2975 while index != -1 and self.queue.startswith(b"<exitcode>"):
2971 try: 2976 try:
2972 task, status = pickle.loads(self.queue[10:index]) 2977 task, status = pickle.loads(self.queue[10:index])
2973 except ValueError as e: 2978 except (ValueError, pickle.UnpicklingError, AttributeError, IndexError) as e:
2974 bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[10:index])) 2979 bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[10:index]))
2975 self.rqexec.runqueue_process_waitpid(task, status) 2980 self.rqexec.runqueue_process_waitpid(task, status)
2976 found = True 2981 found = True