Skip to content

fix(core): fix data corruption in DECIMAL128 and DECIMAL256 columns#6873

Merged
bluestreak01 merged 10 commits intomasterfrom
jh_buggy_set_memory
Mar 17, 2026
Merged

fix(core): fix data corruption in DECIMAL128 and DECIMAL256 columns#6873
bluestreak01 merged 10 commits intomasterfrom
jh_buggy_set_memory

Conversation

@jerrinot
Copy link
Copy Markdown
Contributor

set_memory_vanilla_vec() delegates to run_vec_bulk, which uses TVec::size() as the loop increment.

For Vec8uq that returns 8 (number of uint64_t lanes), but one 512-bit store only covers 4 long_128bit elements or 2 long_256bit elements. The mismatch causes the bulk path to advance past unwritten elements, leaving holes filled with stale data.

Replace the broken run_vec_bulk call in set_memory_vanilla_vec with a dedicated loop that computes the correct per-store element count from sizeof(TVec) / sizeof(T), guarded by a static_assert.

Add VectFuzzTest cases for setMemoryLong128 and setMemoryLong256 with poison-pattern pre-fill and multiple alignment offsets to exercise head, bulk, and tail paths.

set_memory_vanilla_vec() delegates to run_vec_bulk, which uses
TVec::size() as the loop increment.

For Vec8uq that returns 8 (number of uint64_t lanes),
but one 512-bit store only covers 4 long_128bit elements
or 2 long_256bit elements. The mismatch causes the bulk
path to advance past unwritten elements, leaving holes
filled with stale data.

Replace the broken run_vec_bulk call in set_memory_vanilla_vec
with a dedicated loop that computes the correct per-store element
count from sizeof(TVec) / sizeof(T), guarded by a static_assert.

Add VectFuzzTest cases for setMemoryLong128 and setMemoryLong256
with poison-pattern pre-fill and multiple alignment offsets to
exercise head, bulk, and tail paths.
@jerrinot jerrinot added Bug Incorrect or unexpected behavior Core Related to storage, data type, etc. labels Mar 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 28e43ddb-0e19-4076-a844-b2f0155a03db

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jh_buggy_set_memory
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

@jerrinot jerrinot marked this pull request as ready for review March 15, 2026 13:32
@jerrinot
Copy link
Copy Markdown
Contributor Author

expecting tests in this run to fail. then I'll rebuild the native libs and the tests should pass

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes SIMD-accelerated bulk fill for 128-bit and 256-bit “long_*bit” elements by correcting the vector-loop stride, and adds targeted regression tests to detect previously skipped/“hole” elements and sentinel corruption.

Changes:

  • Fix set_memory_vanilla_* vector bulk-fill logic for long_128bit and long_256bit by computing elements-per-store from vector byte width rather than TVec::size().
  • Add regression tests for Vect.setMemoryLong128 and Vect.setMemoryLong256 that validate all elements are written and no overflow occurs.

Reviewed changes

Copilot reviewed 2 out of 5 changed files in this pull request and generated 2 comments.

File Description
core/src/main/c/share/ooo_dispatch.cpp Reworks set_memory_vanilla_vec to use correct SIMD store stride for 128/256-bit element sizes.
core/src/test/java/io/questdb/test/std/VectFuzzTest.java Adds regression tests for setMemoryLong128/256 to catch skipped elements and overflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jerrinot jerrinot marked this pull request as draft March 16, 2026 08:52
@jerrinot jerrinot marked this pull request as ready for review March 16, 2026 09:40
GitHub Actions - Rebuild Native Libraries and others added 2 commits March 16, 2026 09:41
@bluestreak01 bluestreak01 changed the title fix(core): fix SIMD bulk-fill for 128-bit and 256-bit types fix(core): fix data corruption in DECIMAL128 and DECIMAL256 columns Mar 16, 2026
Add non-element-aligned offsets to the DECIMAL128/DECIMAL256 bulk-fill
tests (offset 8 for 128-bit, offset 16 for 256-bit) so the pure-scalar
fallback path in set_memory_vanilla_vec is exercised when
unaligned % sizeof(T) != 0.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@bluestreak01 bluestreak01 merged commit 507109b into master Mar 17, 2026
51 of 52 checks passed
@bluestreak01 bluestreak01 deleted the jh_buggy_set_memory branch March 17, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect or unexpected behavior Core Related to storage, data type, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants