Skip to content

Include the header in the tdigest serialize buffer size - #563

Merged
proost merged 1 commit into
masterfrom
tdigest-serialize-header-size
Oct 30, 2026
Merged

proost merged 1 commit into
masterfrom
tdigest-serialize-header-size

Conversation

@leerho

@leerho leerho commented Oct 29, 2026

Copy link
Copy Markdown
Member

tdigest::serialize(header_size_bytes, with_buffer) allocated get_serialized_size_bytes(with_buffer) bytes but wrote the sketch starting at header_size_bytes, so with a non-zero header the last header_size_bytes bytes were written past the end of the vector. The vector is now header_size_bytes + get_serialized_size_bytes(with_buffer) bytes, as in the other sketches (kll, req, var_opt, ebpps, count_min, bloom_filter, tuple, density).

With the default header size of 0 the output is unchanged.

Tests

New serialize bytes with header case in tdigest_test.cpp: for an empty sketch, a single value (with and without the buffer) and 10000 values (with and without the buffer), the serialized size is the header plus get_serialized_size_bytes(), the bytes after the header match serialize() with no header, and the sketch deserializes from the bytes after the header. Under AddressSanitizer it reports a heap-buffer-overflow on master and passes here; all tdigest tests pass (macOS, Debug, ASan).

🤖 Generated with Claude Code

tdigest::serialize(header_size_bytes, with_buffer) sized the vector by
get_serialized_size_bytes() alone but wrote the sketch starting at
header_size_bytes, so a non-zero header wrote past the end of the
vector. The size now includes the header, as in the other sketches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leerho
leerho requested review from proost and tisonkun October 29, 2026 22:43
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 40966811038

Coverage remained the same at 82.391%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 21523
Covered Lines: 17733
Line Coverage: 82.39%
Coverage Strength: 1378684.83 hits per line

💛 - Coveralls

@proost proost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

This bug affect ds-psql too. After release ds-cpp, we also need new release ds-psql.

@proost
proost merged commit 1ac1323 into master Oct 30, 2026
35 checks passed
@proost
proost deleted the tdigest-serialize-header-size branch October 30, 2026 03:12
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