Skip to content

CBL-8812: Bump fleece submodule, add DeDuplicateEncoder regression test - #2532

Merged
jianminzhao merged 2 commits into
masterfrom
cbl-8812
Sep 1, 2026
Merged

CBL-8812: Bump fleece submodule, add DeDuplicateEncoder regression test#2532
jianminzhao merged 2 commits into
masterfrom
cbl-8812

Conversation

@jianminzhao

Copy link
Copy Markdown
Contributor

Bumps vendor/fleece to pick up the HeapDict::_count fix (see the paired fleece PR for the root-cause writeup): a remove()-then-set() of a key that exists in a MutableDict's immutable _source left count() one too low, corrupting HeapDict::kvArray()'s cache-array sizing -- an out-of-bounds write that only fails cleanly in debug builds (HeapArray::setting()'s bounds check), silently corrupting the heap in shipping builds. Root cause of the crashes reported in CBSE-23608.

Adds a regression test exercising the actual code path that crashed in the field: DeDuplicateEncoder (used only by
VectorRecord::encodeBodyAndExtra) encoding a MutableDict in this remove-then-set state. Before the fix this doesn't fail cleanly -- it crashes the process, since HeapDict::kvArray() is reached through Dict::iterator's public constructor, itself the C-linkage function FLDictIterator_Begin(), and a C++ exception can never safely cross an extern "C" boundary. So the test asserts the correct post-fix behavior (successful encode, correct roundtrip) rather than trying to catch the crash, and is only meaningful -- and only safe to run in CI -- with the fleece fix in place.

Full CppTests suite run clean: 575 cases (572 baseline + 3 new: this one plus the two in the paired fleece PR), 35 pre-existing/unrelated failures (missing test-fixture files), zero new regressions.

Bumps vendor/fleece to pick up the HeapDict::_count fix (see the
paired fleece PR for the root-cause writeup): a remove()-then-set() of
a key that exists in a MutableDict's immutable _source left count()
one too low, corrupting HeapDict::kvArray()'s cache-array sizing --
an out-of-bounds write that only fails cleanly in debug builds
(HeapArray::setting()'s bounds check), silently corrupting the heap
in shipping builds. Root cause of the crashes reported in CBSE-23608.

Adds a regression test exercising the actual code path that crashed
in the field: DeDuplicateEncoder (used only by
VectorRecord::encodeBodyAndExtra) encoding a MutableDict in this
remove-then-set state. Before the fix this doesn't fail cleanly -- it
crashes the process, since HeapDict::kvArray() is reached through
Dict::iterator's public constructor, itself the C-linkage function
FLDictIterator_Begin(), and a C++ exception can never safely cross an
extern "C" boundary. So the test asserts the correct post-fix
behavior (successful encode, correct roundtrip) rather than trying to
catch the crash, and is only meaningful -- and only safe to run in
CI -- with the fleece fix in place.

Full CppTests suite run clean: 575 cases (572 baseline + 3 new: this
one plus the two in the paired fleece PR), 35 pre-existing/unrelated
failures (missing test-fixture files), zero new regressions.
@cbl-bot

cbl-bot commented Sep 1, 2026

Copy link
Copy Markdown

Code Coverage Results:

Type Percentage
branches 64.41
functions 77.38
instantiations 71.02
lines 75.93
regions 72.11

@jianminzhao

Copy link
Copy Markdown
Contributor Author

There is no production code in this PR. The fix is in the linked fleece.

@jianminzhao
jianminzhao merged commit 8b7a110 into master Sep 1, 2026
9 checks passed
@jianminzhao
jianminzhao deleted the cbl-8812 branch September 1, 2026 23:53
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