From a24e52939ed3f044c782d5a3a0cebbc088d81392 Mon Sep 17 00:00:00 2001 From: Simon Liu <331435+monadbobo@users.noreply.github.com> Date: Tue, 22 Oct 2019 17:37:09 +0800 Subject: [PATCH] Issue #1126 graphd crashed Fixed an issue that encountered an unimplemented grammar that could cause a crash. --- src/graph/Executor.cpp | 8 ++++---- src/graph/SequentialExecutor.cpp | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/graph/Executor.cpp b/src/graph/Executor.cpp index f3005c6d29a..7609d64b925 100644 --- a/src/graph/Executor.cpp +++ b/src/graph/Executor.cpp @@ -164,11 +164,11 @@ std::unique_ptr Executor::makeExecutor(Sentence *sentence) { executor = std::make_unique(sentence, ectx()); break; case Sentence::Kind::kUnknown: - LOG(FATAL) << "Sentence kind unknown"; - break; + LOG(ERROR) << "Sentence kind unknown"; + return nullptr; default: - LOG(FATAL) << "Sentence kind illegal: " << kind; - break; + LOG(ERROR) << "Sentence kind illegal: " << kind; + return nullptr; } return executor; } diff --git a/src/graph/SequentialExecutor.cpp b/src/graph/SequentialExecutor.cpp index 45a232fe99f..01b28ec0bc6 100644 --- a/src/graph/SequentialExecutor.cpp +++ b/src/graph/SequentialExecutor.cpp @@ -23,7 +23,9 @@ Status SequentialExecutor::prepare() { for (auto i = 0U; i < sentences_->sentences_.size(); i++) { auto *sentence = sentences_->sentences_[i].get(); auto executor = makeExecutor(sentence); - DCHECK(executor != nullptr); + if (executor == nullptr) { + return Status::Error("The statement has not been implemented"); + } auto status = executor->prepare(); if (!status.ok()) { FLOG_ERROR("Prepare executor `%s' failed: %s",