From 8acfe4aec871f2c678f6af74aaedd09370cca794 Mon Sep 17 00:00:00 2001 From: helloxteen Date: Sat, 13 Sep 2025 19:49:53 +0800 Subject: [PATCH] fix shuffle small memory bug --- .../omniop-spark-extension/cpp/src/jni/deserializer.cpp | 2 +- .../omniop-spark-extension/cpp/src/jni/jni_common.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp b/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp index 69f6ad315..bf8db7099 100644 --- a/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp +++ b/omnioperator/omniop-spark-extension/cpp/src/jni/deserializer.cpp @@ -73,7 +73,7 @@ Java_com_huawei_boostkit_spark_serialize_ShuffleDataSerializerUtils_columnarShuf spark::VecBatch* vecBatch = reinterpret_cast(address); int32_t vecCount = vecBatch->veccnt(); int32_t rowCount = vecBatch->rowcnt(); - omniruntime::vec::BaseVector* vecs[vecCount]; + omniruntime::vec::BaseVector* vecs[vecCount]{}; JNI_FUNC_START jint *typeIdArrayElements = env->GetIntArrayElements(typeIdArray, NULL); diff --git a/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h b/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h index 23fc60039..538543341 100644 --- a/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h +++ b/omnioperator/omniop-spark-extension/cpp/src/jni/jni_common.h @@ -57,9 +57,16 @@ jmethodID GetMethodID(JNIEnv* env, jclass this_class, const char* name, const ch return 0; \ } +/** + * Note: Some vectors may be nullptr if allocation failed + * (e.g., off-heap memory limit exceeded -> MEM_CAP_EXCEEDED). + */ #define JNI_FUNC_END_WITH_VECTORS(exceptionClass, vectors) \ } catch (const std::exception &e) { \ for (auto vec : vectors) { \ + if (vec == nullptr) { \ + continue; \ + } \ delete vec; \ } \ env->ThrowNew(runtimeExceptionClass, e.what()); \ -- Gitee