Skip to content

fix(pool): guard the grow_pool growth-size product against size_t overflow#100

Merged
danielPoloWork merged 1 commit into
masterfrom
fix/grow-pool-overflow-guard
Jun 15, 2026
Merged

fix(pool): guard the grow_pool growth-size product against size_t overflow#100
danielPoloWork merged 1 commit into
masterfrom
fix/grow-pool-overflow-guard

Conversation

@danielPoloWork

Copy link
Copy Markdown
Owner

Summary

Closes the latent size_t overflow in grow_pool's growth-size computation (BUG-0004) — the last of the four verified third-party-reported defects. Core-only, no API change.

Motivation

grow_pool computed total * (grow_factor_ - 1) before any overflow check, then validated add * block_size_ — so the first multiplication could wrap size_t and feed the downstream guard an already-wrapped value. Inconsistent with the meticulous overflow handling on the create path (ADR-0009 §3). Record: BUG-0004.

Changes

  • memory_pool.cpp (grow_pool) — add would_overflow_product(total, grow_factor_ - 1) guard before computing add; on overflow the pool falls back to fixed-mode exhaustion, exactly as the existing guards do.
  • Bug ledger record BUG-0004 (fixed, fixed-in: v1.1.2) + index; CHANGELOG Fixed entry.

Design Patterns

  • None — a defensive guard within the existing dynamic-growth path (ADR-0022/0024).

Verification

  • clang-format + clang-tidy clean on memory_pool.cpp (grow_pool compiles under the default build)
  • python tools/consistency_lint.py — OK; markdownlint-cli2 clean
  • No test added — the overflow is not runtime-reachable through the public API (RAM exhausts long before total nears the boundary); the record documents why
  • Full build matrix — CI

Documentation Impact

  • Bug ledger record + index; CHANGELOG Fixed
  • No README / ROADMAP / ADR change (maintenance fix; PATCH per maintenance.md)
  • PR metadata set — assignee, fix label, v1.1.2 milestone (§6.4 / ADR-0040)

Context

Second and final fix PR for the four reported defects (PR #99 covered the three InstrumentedPool issues). After this merges, v1.1.2 is ready to cut whenever you choose.

🤖 Generated with Claude Code

…rflow

BUG-0004 (low/latent): grow_pool computed `total * (grow_factor_ - 1)`
before any overflow check, then validated `add * block_size_` — so the
first multiplication could wrap size_t and feed the downstream guard an
already-wrapped value. Add a would_overflow_product guard on the
growth-count product first, mirroring the create-path guard; on overflow
the pool falls back to fixed-mode exhaustion (returns false).

Not runtime-reachable through the public API (RAM exhausts long before
`total` nears the overflow boundary), so no test is added — it is a
correctness/consistency gap closed by inspection. Recorded as BUG-0004
(fixed-in v1.1.2) in the bug ledger.

Verified: clang-format / clang-tidy clean on memory_pool.cpp, consistency
lint + markdownlint green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@danielPoloWork danielPoloWork added this to the v1.1.2 milestone Jun 15, 2026
@danielPoloWork danielPoloWork added the fix Bug fix (Conventional Commit: fix) label Jun 15, 2026
@danielPoloWork danielPoloWork self-assigned this Jun 15, 2026
@danielPoloWork danielPoloWork merged commit 10d6ad6 into master Jun 15, 2026
32 checks passed
@danielPoloWork danielPoloWork mentioned this pull request Jun 15, 2026
6 tasks
danielPoloWork added a commit that referenced this pull request Jun 15, 2026
## Summary
Cuts the **v1.1.2** maintenance release — a **PATCH** bundling the four
verified bug fixes (BUG-0001…0004, the first real use of the in-repo bug
ledger) and the documentation work accumulated since `v1.1.1`. The
library's public surface is unchanged (no API/ABI change). Full notes:
[`docs/releases/v1.1.2.md`](docs/releases/v1.1.2.md).

## Motivation
SemVer PATCH per the [maintenance decision
tree](docs/workflow/maintenance.md) (no public-surface change).
Mechanics per [`docs/workflow/release.md`](docs/workflow/release.md).

## Changes
- **`version.hpp`** — PATCH `1 → 2`, STRING `"1.1.1" → "1.1.2"`;
`pool_smoke` version `TEST_CASE` updated.
- **`CHANGELOG.md`** — `[Unreleased]` rolled into the immutable
[`docs/changelog/v1/v1.1.2.md`](docs/changelog/v1/v1.1.2.md) (links
re-based), `Unreleased` reset, index row added, compare link →
`v1.1.2...HEAD`.
- **`docs/releases/v1.1.2.md`** — draft GitHub Release notes.
- **`README.md`** — status badge → `v1.1.2` + a new `v1.1.2` status
paragraph.
- **i18n** — the two README translation rows marked `stale` (English
README changed); the `zh-Hans`/`ja` re-sync is a follow-up. The
`i18n-freshness` lint skips `stale` rows, so the gate stays green.

## Release contents
**Fixed:** BUG-0001 (InstrumentedPool growth-counter data race),
BUG-0002 (`live_` underflow + header doc), BUG-0003 (move-assign
`destroyed` event), BUG-0004 (`grow_pool` overflow guard). **Removed:**
the `docs-site` README badge. **Changed:** `zh-Hans`/`ja` README
re-synced to v1.1.1. ADR total stays 40.

## Design Patterns
- None — release bookkeeping.

## Verification
- [x] `python tools/consistency_lint.py` — OK (version-lockstep sees
`version.hpp`/CHANGELOG/README badge/release notes all at `1.1.2`;
`i18n-freshness` green)
- [x] `markdownlint-cli2` + `clang-format` clean
- [ ] CI build matrix + ASan/UBSan/TSan — validated on this PR (the bug
fixes themselves landed and passed CI in #99/#100)

## Documentation Impact
- [x] README badge + paragraph; CHANGELOG rolled; release notes added
- [x] ROADMAP — N/A (maintenance PATCH, no milestone change)
- [x] PR metadata set — assignee, `chore` label, `v1.1.2` milestone
(§6.4 / ADR-0040)

## After merge
The agent tags `v1.1.2` from `master`
([ADR-0008](docs/adr/0008-delegate-tag-creation-and-push-to-the-agent.md));
`release.yml` produces a **draft** GitHub Release; the maintainer clicks
*Publish*. Then a follow-up PR re-syncs the `zh-Hans`/`ja` README
translations to `v1.1.2` and closes the `v1.1.2` milestone.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix (Conventional Commit: fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant