Skip to content

[C++] Initialize oversized PageArena allocation metadata - #1033

Open
zhangxinyao88 wants to merge 2 commits into
apache:developfrom
zhangxinyao88:codex/tsfile-page-arena-large-allocation
Open

zhangxinyao88 wants to merge 2 commits into
apache:developfrom
zhangxinyao88:codex/tsfile-page-arena-large-allocation

Conversation

@zhangxinyao88

@zhangxinyao88 zhangxinyao88 commented Oct 24, 2026 •

Copy link
Copy Markdown

Allocations larger than the arena page size construct a page with null cursor/end pointers. get_total_used_bytes() then subtracts from null and returns a negative total. A subsequent small allocation reaches Page::alloc() on that block; the existing AlignmentWithBuildinTypes test reports applying non-zero offset 8 to null pointer under UBSan.

Initialize the oversized block with its payload size and mark it fully consumed. This makes accounting accurate and prevents reuse while retaining the existing payload address/alignment. Check allocation failure before placement construction and remove the unused null-state constructor.

Add two regressions for exact used-byte totals, consecutive oversized blocks, preserved payload bytes and reset. Both fail on current develop with negative totals; all seven affected PageArena cases pass with the fix under ASan/UBSan and halt-on-error, including the existing alignment case.

Validation on macOS arm64, Java 17 and clang-format 17.0.6:

  • ./mvnw -B -ntp -P with-cpp -Denable.lzma2=ON verify: 1,165 passed, 3 skipped, 10 disabled, 0 failed; Spotless, Checkstyle and RAT pass. All configured codecs, ANTLR and SIMD are enabled.
  • Separate Debug ASan/UBSan build: all seven PageArena tests pass. Actual library/test compile flags, sanitizer symbols and runtime linkage were checked. Optional codecs, ANTLR and SIMD are disabled in this build.

The sanitizer build explicitly supplies sanitizer flags through CXXFLAGS because the existing CMake configuration drops its own instrumentation flags; that build-system repair is checkpointed separately. Full sanitizer, local Windows, Java and Python runtime suites were not run for this allocator patch.

Discovered while investigating sanitizer instrumentation after #1030. The prior alignment fix #527 is retained; this fixes oversized-page metadata. Build configuration, Python sanitizer coverage (#1027), and other PR scopes remain separate.

Existing-PR CI setup repair — 2026-10-25

Commit 233e63e1ed895ad229b41c77901e1439eb723729 applies shared 002d798: install pinned clang-format 17.0.6 in a runner-local venv, explicitly set up Python 3.11 for C++ Linux, and move only the Python 3.9 Linux cell to supported Ubuntu 22.04. All 8 C++ / 9 Python jobs, build/test commands, triggers and permissions are retained. No additional production changes.

Both workflows pass actionlint, YAML/bash syntax and matrix checks. The original dependency blocks reproduce the missing-formatter failure with mocked system package operations; repaired blocks actually install/run 17.0.6 and resolve the next-step PATH on macOS. The current official setup-python manifest confirms Python 3.9.25 x64 Linux support on 22.04 and absence on 26.04. Linux container and full application tests were not rerun for this YAML-only change.

At this exact new head: 0 check-runs and 10 workflows awaiting maintainer approval. Prior-head runtime results above are historical. No new-head runtime pass, CI approval or rerun is claimed.

Represent a dedicated oversized block as a fully consumed page. Its
null cursor previously broke used-byte accounting and triggered UBSan
when a later small allocation tried to reuse the block.

Cover used-byte totals, successive oversized blocks, retained data and
reset. Preserve the existing payload address and alignment.
Install clang-format 17.0.6 in a runner-local virtual environment rather than assuming /usr/bin/clang-format-17 exists. Keep the Python 3.9 Linux job on Ubuntu 22.04, where setup-python provides its binary, while retaining all nine Python matrix combinations.

Generated-by: OpenAI Codex
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.

1 participant