Fix: cap absvector size so a huge request is a catchable error, not a heap-exhaustion abort - #5
Fix: cap absvector size so a huge request is a catchable error, not a heap-exhaustion abort#5pyrex41 wants to merge 1 commit into
Conversation
(absvector HUGE) handed make-array a size far larger than the heap, which SBCL reports as an *uncatchable* "Heap exhausted" abort -- trap-error cannot recover, so one bad size takes down the whole image. Fix: validate the requested size in |absvector|. A non-negative integer up to a sanity cap of 2^24 (16,777,216) slots allocates as before; anything larger, negative, or non-integer raises a catchable Shen error via simple-error instead of attempting the allocation. The cap is over 800x the largest vector the kernel itself ever allocates (the 20000-slot property dictionary), so it cannot break legitimate kernel or program use. Test: tests/primitives-tests.shen gains issue #3 regressions, including the exact form from the issue -- (trap-error (absvector 100000000000) (lambda E true)) => true -- plus over-cap/negative catchability and a large-but-legal allocation that still succeeds. Canonical SBCL cert 134/134 100%, compiler tests pass, port suite 130/130. Fixes #3 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Independent agent review (ratatoskr + ShenSpec deep-dive, post-load native override discipline, 134/134 cert preserved) Code Review: PR #5PR: #5
Process followed: Read diff first, then all instructed sources + surrounding allocation/sentinel/error paths. Broad SummaryOverall verdict: APPROVE (with minor observations). The change is correct, minimal, and directly solves the reported problem (Shen issue #3). A huge Correctness (primary):
Rationale + scale verification (ratatoskr angle):
Tests / ShenSpec angle (primitives-tests.shen):
Error handling / primitives layer:
Other notes (no high-severity findings):
Related observation (not a defect in this PR): The user-level The fix is a clean, well-tested safety bound that turns a fatal abort into a catchable Shen error while preserving all prior behavior for valid inputs. 134/134 + port suite green is the expected outcome. IssuesSeverity: Low (documentation/scope observation, not a correctness defect) Severity: Info (style / future-proofing) Severity: Info (test completeness / edge) Severity: None (positive finding; no issue) Severity: None (positive; verification) No other issues found (no error-handling gaps, no race conditions, no incorrect sentinel logic, no changes to |absvector?| or address ops, no impact on certification paths or ratatoskr builders). The patch is ready to land. End of review. Review artifacts written to the path above. The change meets the "correctness first" bar with clear, testable hardening of a foot-gun primitive while preserving the success path and adding executable-spec coverage. Posted automatically by Grok reviewer subagents. See also the PENDING review (if any) for inline comments on the Files tab. |
|
From independent reviewer subagent (ratatoskr/KLambda scale verification for the 800x claim, primitives layer, test-harness integration, and portable KL vs. native override paths): Low (documentation/scope observation)
Info (style / future-proofing)
Info (test completeness / edge)
Strong positives: Predicate tight (integerp + range, short-circuit and), error via |simple-error| (catchable), success path identical for valid sizes, |fail| sentinel untouched, ratatoskr/KLambda searches confirm max kernel usage ~20k (dict/prolog etc.), tests pin the exact contract from the issue using both trap-error and assert-caught. No changes to |absvector?| or address ops. Full ratatoskr verification in the previous top-level comment. APPROVE per subagent (with minor observations). |
Summary
(absvector HUGE)handedmake-arraya size far larger than the heap. On SBCL this is an uncatchableHeap exhaustedabort --trap-errorcannot recover from it, so a single bad size takes down the whole image:Fix
src/primitives.lsp: validate the requested size in|absvector|. A non-negative integer up to a sanity cap of2^24(16,777,216) slots allocates exactly as before; anything larger, negative, or non-integer raises a catchable Shen error viasimple-errorinstead of attempting the allocation.The cap is over 800x the largest vector the kernel itself ever allocates (the 20000-slot property dictionary used by
(dict 20000)), so it cannot break any legitimate kernel or program use. It is portable CL and so protects every impl, while the heap-exhaustion abort it prevents is the SBCL failure mode from the issue.Test
tests/primitives-tests.shengains issue #3 regressions, including the exact form requested in the issue:plus over-cap and negative-size catchability, and a large-but-legal
(absvector 1000000)that still allocates.Results
Rebuilt the SBCL image.
make test-sbcl): 134/134, 100%make test-compiler): passmake test-port): 130/130Fixes #3
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com