Skip to content

CBL-8726 : Fix use after free in the lazy vector index tests - #3559

Merged
pasin merged 1 commit into
masterfrom
CBL-8726
Aug 18, 2026
Merged

CBL-8726 : Fix use after free in the lazy vector index tests#3559
pasin merged 1 commit into
masterfrom
CBL-8726

Conversation

@pasin

@pasin pasin commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

vectorForWord: returned the CBLArray from a query result, cast to NSArray. That array is only valid while the result set is alive, so callers read freed memory once the enumeration ended. The result was an EXC_BAD_ACCESS crash inside -[CBLIndexUpdater setVector:atIndex:error:] and wrong vectors in the assertions. It only showed up when running against release builds. Copy the values out with -[CBLArray toArray] instead.

vectorForWord: returned the CBLArray from a query result, cast to
NSArray. That array is only valid while the result set is alive, so
callers read freed memory once the enumeration ended. The result was an
EXC_BAD_ACCESS crash inside -[CBLIndexUpdater setVector:atIndex:error:]
and wrong vectors in the assertions. It only showed up when running
against release builds. Copy the values out with -[CBLArray toArray]
instead.
@pasin
pasin requested review from jianminzhao and a lite review from Copilot August 18, 2026 04:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the lazy vector search test helper to detach vector values from a result-set–scoped CBLArray by converting it to a Foundation array before returning.

Changes:

  • Treat the query result value as CBLArray* instead of id.
  • Convert the fleece-backed CBLArray to an NSArray via toArray before returning.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Objective-C/Tests/VectorSearchTest+Lazy.m
@pasin
pasin merged commit db1abd2 into master Aug 18, 2026
9 checks passed
@pasin
pasin deleted the CBL-8726 branch August 18, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants