Skip to content

Commit

Permalink
[GLUTEN-4422][CORE] Fix core dump caused by spill on closed iterator (#…
Browse files Browse the repository at this point in the history
…5874)

Closes #4422
  • Loading branch information
WangGuangxin authored May 29, 2024
1 parent d7374bd commit 79c681b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cpp/core/jni/JniWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ JNIEXPORT jlong JNICALL Java_org_apache_gluten_vectorized_ColumnarBatchOutIterat
auto ctx = gluten::getRuntime(env, wrapper);

auto it = ctx->objectStore()->retrieve<ResultIterator>(iterHandle);
if (it == nullptr) {
std::string errorMessage = "Invalid result iter handle " + std::to_string(iterHandle);
throw gluten::GlutenException(errorMessage);
}
return it->spillFixedSize(size);
JNI_METHOD_END(kInvalidResourceHandle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public IMetrics getMetricsInternal() throws IOException, ClassNotFoundException
}

public long spill(long size) {
return nativeSpill(iterHandle, size);
if (!closed.get()) {
return nativeSpill(iterHandle, size);
} else {
return 0L;
}
}

@Override
Expand Down

0 comments on commit 79c681b

Please sign in to comment.