From b020384e8534defcc3bc801ddeef67fd7980a389 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 27 Jun 2020 13:04:32 +0100 Subject: bitbake: runqueue: Avoid unpickle errors in rare cases In rare cases the pickled data from a task contains "" which causes backtrace. This can be reproduced with something like: do_unpack_prepend () { bb.warn("") } 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 (Bitbake rev: 6d780fe3a111adbf3f3d2dda22d5a0787b195b62) Signed-off-by: Richard Purdie (cherry picked from commit 5ada512d6f9cbbdf1172ff7818117c38b12225ca) Signed-off-by: Steve Sakoman Signed-off-by: Richard Purdie --- bitbake/lib/bb/runqueue.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bitbake') 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(): while index != -1 and self.queue.startswith(b""): try: event = pickle.loads(self.queue[7:index]) - except ValueError as e: + except (ValueError, pickle.UnpicklingError, AttributeError, IndexError) as e: + if isinstance(e, pickle.UnpicklingError) and "truncated" in str(e): + # The pickled data could contain "" so search for the next occurance + # unpickling again, this should be the only way an unpickle error could occur + index = self.queue.find(b"", index + 1) + continue bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[7:index])) bb.event.fire_from_worker(event, self.d) if isinstance(event, taskUniHashUpdate): @@ -2970,7 +2975,7 @@ class runQueuePipe(): while index != -1 and self.queue.startswith(b""): try: task, status = pickle.loads(self.queue[10:index]) - except ValueError as e: + except (ValueError, pickle.UnpicklingError, AttributeError, IndexError) as e: bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[10:index])) self.rqexec.runqueue_process_waitpid(task, status) found = True -- cgit v1.2.3-54-g00ecf