From c19290b1ba51ad180184887c3293e51297f0b14d Mon Sep 17 00:00:00 2001 From: "shengjun.li" Date: Fri, 30 Apr 2021 11:01:18 +0800 Subject: [PATCH] fix crash when creating a GPU IVF index (#5097) Signed-off-by: shengjun.li --- CHANGELOG.md | 1 + .../thirdparty/faiss/gpu/utils/StackDeviceMemory.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cabb7d2896..015e767966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Please mark all change in change log and use the issue from GitHub - \#5010 IVF_PQ failed to query on GPU if 'nbits' doesn't equal to 8 - \#5050 Index type returned by get_collection_stats() is incorrect - \#5063 Empty segment is serialized and crash milvus +- \#5078 Server crashed when creaing a GPU IVF index whose dimension is 2048/4086/8192 ## Feature - \#4564 Allow get_entity_by_id() in a specified partition diff --git a/core/src/index/thirdparty/faiss/gpu/utils/StackDeviceMemory.cpp b/core/src/index/thirdparty/faiss/gpu/utils/StackDeviceMemory.cpp index ef357047ed..1b8282e4d6 100644 --- a/core/src/index/thirdparty/faiss/gpu/utils/StackDeviceMemory.cpp +++ b/core/src/index/thirdparty/faiss/gpu/utils/StackDeviceMemory.cpp @@ -65,6 +65,10 @@ StackDeviceMemory::Stack::getSizeAvailable() const { char* StackDeviceMemory::Stack::getAlloc(size_t size, cudaStream_t stream) { + if (size == 0) { + return nullptr; + } + if (size > (end_ - head_)) { // Too large for our stack DeviceScope s(device_); @@ -133,6 +137,10 @@ void StackDeviceMemory::Stack::returnAlloc(char* p, size_t size, cudaStream_t stream) { + if (size == 0) { + return; + } + if (p < start_ || p >= end_) { // This is not on our stack; it was a one-off allocation DeviceScope s(device_);