A completed order-8 run therefore probes beyond the grid. An out-of-tree AddressSanitizer build confirmed a heap-buffer overflow.
Proposed work
Check for completion immediately after next_pos().
Do not call largest_square() with the end sentinel.
Add a focused regression test that completes a board under AddressSanitizer.
Acceptance criteria
Order 8 completes without sanitizer findings.
Debug assertions remain enabled and pass.
A regression test would fail with the old ordering.
The fix is committed separately from performance changes.
Reference
main.cc:295-299
## Background
After placing a square, the solver calls `largest_square(pos, n)` before checking whether `next_pos()` returned `grid.end()`:
```cpp
pos = grid.next_pos(pos + idx);
idx = grid.largest_square(pos, n);
if (pos == grid.end()) { break; }
```
A completed order-8 run therefore probes beyond the grid. An out-of-tree AddressSanitizer build confirmed a heap-buffer overflow.
## Proposed work
- Check for completion immediately after `next_pos()`.
- Do not call `largest_square()` with the end sentinel.
- Add a focused regression test that completes a board under AddressSanitizer.
## Acceptance criteria
- Order 8 completes without sanitizer findings.
- Debug assertions remain enabled and pass.
- A regression test would fail with the old ordering.
- The fix is committed separately from performance changes.
## Reference
- `main.cc:295-299`
Implemented on codex/issue-14-completion-check as two separate commits:
ccdcf03 adds a focused solver-completion regression for orders 1 and 8. Both results are checked by the independent validator for board dimensions, multiplicities, bounds, overlap, and complete coverage. Before the fix, the focused ASan run aborts on order 1 with a heap-buffer-overflow in find_solution().
ce39d0a moves the completion check immediately after next_pos() so the end sentinel is never passed to largest_square().
The minimal fix preserves solver behavior for non-terminal positions. Full CTest suites pass in Debug, Release, ASan, and UBSan configurations (5/5 each); the order-8 solver result is independently validated by the new regression.
Implemented on `codex/issue-14-completion-check` as two separate commits:
- `ccdcf03` adds a focused `solver-completion` regression for orders 1 and 8. Both results are checked by the independent validator for board dimensions, multiplicities, bounds, overlap, and complete coverage. Before the fix, the focused ASan run aborts on order 1 with a heap-buffer-overflow in `find_solution()`.
- `ce39d0a` moves the completion check immediately after `next_pos()` so the end sentinel is never passed to `largest_square()`.
The minimal fix preserves solver behavior for non-terminal positions. Full CTest suites pass in Debug, Release, ASan, and UBSan configurations (5/5 each); the order-8 solver result is independently validated by the new regression.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Background
After placing a square, the solver calls
largest_square(pos, n)before checking whethernext_pos()returnedgrid.end():A completed order-8 run therefore probes beyond the grid. An out-of-tree AddressSanitizer build confirmed a heap-buffer overflow.
Proposed work
next_pos().largest_square()with the end sentinel.Acceptance criteria
Reference
main.cc:295-299Implemented on
codex/issue-14-completion-checkas two separate commits:ccdcf03adds a focusedsolver-completionregression for orders 1 and 8. Both results are checked by the independent validator for board dimensions, multiplicities, bounds, overlap, and complete coverage. Before the fix, the focused ASan run aborts on order 1 with a heap-buffer-overflow infind_solution().ce39d0amoves the completion check immediately afternext_pos()so the end sentinel is never passed tolargest_square().The minimal fix preserves solver behavior for non-terminal positions. Full CTest suites pass in Debug, Release, ASan, and UBSan configurations (5/5 each); the order-8 solver result is independently validated by the new regression.