Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the crash caused by failed downcast of iter #5291

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/graph/executor/algo/SubgraphExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,20 @@ folly::Future<Status> SubgraphExecutor::handleResponse(RpcResponse&& resps) {

void SubgraphExecutor::filterEdges(int version) {
auto iter = ectx_->getVersionedResult(subgraph_->outputVar(), version).iter();
auto* gnIter = static_cast<GetNeighborsIter*>(iter.get());
while (gnIter->valid()) {
const auto& dst = gnIter->getEdgeProp("*", nebula::kDst);
if (validVids_.find(dst) == validVids_.end()) {
auto edge = gnIter->getEdge();
gnIter->erase();
} else {
gnIter->next();
auto* iterPtr = iter.get();
if (iterPtr->isGetNeighborsIter()) {
auto* gnIter = static_cast<GetNeighborsIter*>(iterPtr);
while (gnIter->valid()) {
const auto& dst = gnIter->getEdgeProp("*", nebula::kDst);
if (validVids_.find(dst) == validVids_.end()) {
auto edge = gnIter->getEdge();
gnIter->erase();
} else {
gnIter->next();
}
}
gnIter->reset();
}
gnIter->reset();
ResultBuilder builder;
builder.iter(std::move(iter));
ectx_->setVersionedResult(subgraph_->outputVar(), builder.build(), version);
Expand Down
3 changes: 3 additions & 0 deletions src/graph/executor/query/DataCollectExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Status DataCollectExecutor::collectSubgraph(const std::vector<std::string>& vars
ds.colNames = std::move(colNames_);
const auto& hist = ectx_->getHistory(vars[0]);
for (const auto& result : hist) {
if (!result.iterRef()->isGetNeighborsIter()) {
continue;
}
auto iter = result.iter();
auto* gnIter = static_cast<GetNeighborsIter*>(iter.get());
List vertices;
Expand Down
23 changes: 23 additions & 0 deletions tests/tck/features/bugfix/FixIterCrash.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2022 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: FixIterCrash

Scenario: Fix GetNeighborsIter Crash
Given an empty graph
And having executed:
"""
CREATE SPACE nba_FixIterCrash as nba
"""
And wait 6 seconds
And having executed:
"""
USE nba_FixIterCrash
"""
When executing query:
"""
GO from 'Tim Duncan' OVER serve YIELD serve._src AS id |
GET SUBGRAPH WITH PROP FROM $-.id
YIELD vertices as nodes, edges as relationships
"""
Then the execution should be successful