milvus-io / milvus-sdk-go

Go SDK for Milvus.
Apache License 2.0
354 stars 110 forks source link

[Bug]: panic: runtime error: slice bounds out of range when search with sparse vector #728

Closed ThreadDao closed 7 months ago

ThreadDao commented 7 months ago

Is there an existing issue for this?

Current Behavior

milvus: master-20240415-fd971a43-amd64 sdk: go master

search with sparse vector field and panic:

2024/04/17 16:02:26 milvus_client.go:14: (ApiRequest): func [Search], args: [context.Background.WithDeadline(2024-04-17 16:06:15.992850747 +0800 CST m=+240.004269159 [3m49.172233259s]) VSWV []  [*] nq=1 sparseVec IP 10 0xc000011c38 []]
2024/04/17 16:02:26 milvus_client.go:14: (ApiRequest): func [DropCollection], args: [context.Background.WithDeadline(2024-04-17 16:06:15.992850747 +0800 CST m=+240.004269159 [3m49.172050076s]) VSWV]
2024/04/17 16:02:26 milvus_client.go:21: (ApiResponse): func [DropCollection], results: []
2024/04/17 16:02:26 milvus_client.go:14: (ApiRequest): func [Close], args: []
2024/04/17 16:02:26 milvus_client.go:21: (ApiResponse): func [Close], results: []
--- FAIL: TestSearchSparseVector (10.84s)
panic: runtime error: slice bounds out of range [60:48] [recovered]
    panic: runtime error: slice bounds out of range [60:48]

goroutine 6 [running]:
testing.tRunner.func1.2({0xba6320, 0xc0004cab88})
    /usr/local/go/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
    /usr/local/go/src/testing/testing.go:1392 +0x39f
panic({0xba6320, 0xc0004cab88})
    /usr/local/go/src/runtime/panic.go:838 +0x207
github.com/milvus-io/milvus-sdk-go/v2/entity.sliceSparseEmbedding.Serialize({{0xc0004cab40, 0x6, 0x6}, {0xc0004cab58, 0x6, 0x6}, 0xc, 0x6})
    /home/zong/zong/go-projects/milvus-sdk-go/entity/columns_sparse.go:66 +0x225
github.com/milvus-io/milvus-sdk-go/v2/client.vector2Placeholder({0xc00031da80, 0x1, 0xc000f45838?})
    /home/zong/zong/go-projects/milvus-sdk-go/client/insert.go:520 +0x1e5
github.com/milvus-io/milvus-sdk-go/v2/client.vector2PlaceholderGroupBytes({0xc00031da80?, 0xc000f45838?, 0xc0e037?})
    /home/zong/zong/go-projects/milvus-sdk-go/client/insert.go:489 +0x25
github.com/milvus-io/milvus-sdk-go/v2/client.prepareSearchRequest({0xc00048e168, 0x4}, {0x1219190, 0x0, 0x0}, {0x0, 0x0}, {0xc00031da90, 0x1, 0x1}, ...)
    /home/zong/zong/go-projects/milvus-sdk-go/client/data.go:418 +0x75a
github.com/milvus-io/milvus-sdk-go/v2/client.(*GrpcClient).Search(0xc0000888c0, {0xd18978, 0xc000046ba0}, {0xc00048e168, 0x4}, {0x1219190, 0x0, 0x0}, {0x0, 0x0}, ...)
    /home/zong/zong/go-projects/milvus-sdk-go/client/data.go:115 +0x210
github.com/milvus-io/milvus-sdk-go/v2/test/base.(*MilvusClient).Search(0xc00048c4f0, {0xd18978?, 0xc000046ba0}, {0xc00048e168, 0x4}, {0x1219190, 0x0, 0x0}, {0x0, 0x0}, ...)
    /home/zong/zong/go-projects/milvus-sdk-go/test/base/milvus_client.go:423 +0x5a3
github.com/milvus-io/milvus-sdk-go/v2/test/testcases.TestSearchSparseVector(0x0?)
    /home/zong/zong/go-projects/milvus-sdk-go/test/testcases/search_test.go:1621 +0x77b
testing.tRunner(0xc00036c9c0, 0xc56a80)
    /usr/local/go/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:1486 +0x35f

Expected Behavior

No response

Steps To Reproduce

No response

Environment

No response

Anything else?

No response

ThreadDao commented 7 months ago

/assign @congqixia

ThreadDao commented 7 months ago

fixed