[vm] Account for Out Of Memory during isolate message deserialization.

TEST=run test harness with low heap limit
Change-Id: I75d3b2e8461bcf99cc41eb3ad76173bc1976bbd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213538
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2021-09-16 17:18:37 +00:00 committed by commit-bot@chromium.org
parent 5110d828d0
commit 790d0b601c
2 changed files with 11 additions and 8 deletions

View file

@ -16,11 +16,9 @@ class Error;
class LongJumpScope : public StackResource {
public:
LongJumpScope()
: StackResource(ThreadState::Current()),
top_(nullptr),
base_(thread()->long_jump_base()) {
thread()->set_long_jump_base(this);
explicit LongJumpScope(ThreadState* thread = ThreadState::Current())
: StackResource(thread), top_(nullptr), base_(thread->long_jump_base()) {
thread->set_long_jump_base(this);
}
~LongJumpScope() {

View file

@ -3745,7 +3745,7 @@ std::unique_ptr<Message> WriteMessage(bool can_send_any_object,
volatile bool has_exception = false;
{
LongJumpScope jump;
LongJumpScope jump(thread);
if (setjmp(*jump.Set()) == 0) {
serializer.Serialize(obj);
} else {
@ -3820,8 +3820,13 @@ ObjectPtr ReadMessage(Thread* thread, Message* message) {
return ReadObjectGraphCopyMessage(thread, message->persistent_handle());
} else {
RELEASE_ASSERT(message->IsSnapshot());
MessageDeserializer deserializer(thread, message);
return deserializer.Deserialize();
LongJumpScope jump(thread);
if (setjmp(*jump.Set()) == 0) {
MessageDeserializer deserializer(thread, message);
return deserializer.Deserialize();
} else {
return thread->StealStickyError();
}
}
}