diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-27 13:04:32 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-28 08:36:56 +0100 |
commit | 118f009cee84f991ebd2f28b6e27a92519584589 (patch) | |
tree | 1334be156ae5105bb77d19ac58ca891e7f327610 /bitbake | |
parent | 90c3713590fccf92907edf8ccf9e6342b626327f (diff) | |
download | poky-118f009cee84f991ebd2f28b6e27a92519584589.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: 5ada512d6f9cbbdf1172ff7818117c38b12225ca)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index adb34a8cf2..02a261e30c 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -2967,7 +2967,12 @@ class runQueuePipe(): | |||
2967 | while index != -1 and self.queue.startswith(b"<event>"): | 2967 | while index != -1 and self.queue.startswith(b"<event>"): |
2968 | try: | 2968 | try: |
2969 | event = pickle.loads(self.queue[7:index]) | 2969 | event = pickle.loads(self.queue[7:index]) |
2970 | except ValueError as e: | 2970 | except (ValueError, pickle.UnpicklingError, AttributeError, IndexError) as e: |
2971 | if isinstance(e, pickle.UnpicklingError) and "truncated" in str(e): | ||
2972 | # The pickled data could contain "</event>" so search for the next occurance | ||
2973 | # unpickling again, this should be the only way an unpickle error could occur | ||
2974 | index = self.queue.find(b"</event>", index + 1) | ||
2975 | continue | ||
2971 | bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[7:index])) | 2976 | bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[7:index])) |
2972 | bb.event.fire_from_worker(event, self.d) | 2977 | bb.event.fire_from_worker(event, self.d) |
2973 | if isinstance(event, taskUniHashUpdate): | 2978 | if isinstance(event, taskUniHashUpdate): |
@@ -2979,7 +2984,7 @@ class runQueuePipe(): | |||
2979 | while index != -1 and self.queue.startswith(b"<exitcode>"): | 2984 | while index != -1 and self.queue.startswith(b"<exitcode>"): |
2980 | try: | 2985 | try: |
2981 | task, status = pickle.loads(self.queue[10:index]) | 2986 | task, status = pickle.loads(self.queue[10:index]) |
2982 | except ValueError as e: | 2987 | except (ValueError, pickle.UnpicklingError, AttributeError, IndexError) as e: |
2983 | bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[10:index])) | 2988 | bb.msg.fatal("RunQueue", "failed load pickle '%s': '%s'" % (e, self.queue[10:index])) |
2984 | self.rqexec.runqueue_process_waitpid(task, status) | 2989 | self.rqexec.runqueue_process_waitpid(task, status) |
2985 | found = True | 2990 | found = True |