P1: before the tag
An appendix to the milestone.
P1: before the first tag
-
The public arithmetic takes bare
usizeand has three edges noLayoutreaches. Finding:class(size, align)roundssizewithnext_multiple_of(GRID)before it compares toLARGEST(src/lib.rslines 66 to 74). In release,class(usize::MAX, 8)wraps to zero, passes the bound and returnsSome(18446744073709551615)(verified); in debug it panics.class_bytes(c)computes(c + 1) * GRID(src/lib.rsline 79), which overflows the same way on a large index (inferred).count,takeandputindexheadsandcountswith the bare index, so a class at or pastCLASSESpanics on bounds (verified forcount). None of this is reachable through a validLayout, whose size is at mostisize::MAX(verified:class(isize::MAX as usize, 8)isNone), and thestdconsumer only passes layouts. The compiler catches a stranger who calls theconst fnwith a literal; it does not catch one who calls it with a runtimeusize. Change: compare before rounding (if size > LARGEST { return None }), which is also one fewer operation on the allocator's fast path, or usechecked_next_multiple_of. Add the edge tests the standalone copy ran. The index problem is a type problem, and the fix is theClassnewtype that Decision 3 decides:classreturnsOption<Class>and every method that takes a class takesClass. Door: two-way before the first tag. Effort: S. -
The consumer relies on "zeroed is empty", and the crate neither states nor tests it. Finding: the thread block in the
stdoverlay holds aCachein zeroed memory. Its field comment says "Zeroed is empty, so a fresh block needs no setup" (patches/std-nife/overlay/std/src/sys/thread_local/key/nife.rslines 50 to 51).Cache::newwrites null heads and zero counts (src/lib.rslines 139 to 144), so the claim is true today. Nothing in the crate says a later field may not break it. A test that reads acore::mem::zeroed::<Cache>()as empty passes (verified on the standalone copy). Change: one sentence onCache("an all-zeroCacheis empty, so it can live in memory a runtime zeroes") and that test. Door: two-way. Effort: S. -
put's safety contract stops short of whatspillanddrainlater assume. Finding:putasks forclass_bytes(class)writable grid-aligned bytes used by nothing else (src/lib.rslines 169 to 172). That is enough for the cache's own soundness. But every block the cache hands tospill's ordrain's callback goes to a heap underclass_layout(class)in both the host test and the consumer (src/lib.rslines 411 and 423;patches/std-nife/overlay/std/src/sys/alloc/nife/entry.rsline 43). A block that merely satisfiesput(a slice of a stack array, as the doc example uses) must never reach aspillinto a heap. The crate does not say where that obligation lives. Change:Cache's doc states the owner's rule. A block goes into aCachethe owner means tospillordraininto a heap only if that heap will accept it underclass_layout(class).put's# Safetypoints to it.spillanddrainsay they hand back only whatputandrefilltook. Door: two-way. Effort: S. -
Five constant names carry no unit or name no thing, against the naming rules this tree applies at a release review. Finding:
GRIDis 16 bytes andLARGESTis 256 bytes (src/lib.rslines 42 and 45); the units rule says a length or a limit carries its unit, and a limit opensMAXIMUM_.DEPTHandBATCHcount blocks (src/lib.rslines 51 and 56). The rule says a count of things names the things.MOST_CACHED_BYTES(src/lib.rsline 59) opens withMOST_where the rule writesMAXIMUM_. The template'sunit_symbolsgate passes all five because none carries a symbol; the rule is one that a reader applies. The methodsputanddraindo not take std's spelling and meaning where std has one:putis glibc's word for what std andheaplesscallpush, with the sameResult<(), T>shape on a full container. std'sdrainreturns an iterator where this one takes a closure.takematches std's meaning. Change: as Decision 2 decides:GRID_BYTES,MAXIMUM_CLASS_BYTES,BLOCKS_PER_CLASS,BATCH_BLOCKS,MAXIMUM_CACHED_BYTES,pushforput,popfortake, andgive_back_allfordrainunless it comes to return an iterator. The lane renames in one pass before the move, and the consumer's threeusesites follow. Door: two-way before the first tag. Effort: S. -
The crate is
unsafeat its core and has no proof. Finding: 22unsafesites, 7 of them in production code, each with aSAFETYcomment a reader can check (src/lib.rslines 87, 105, 161, 181 and 217; the twounsafe fnbodies). Kani harnesses: none; falsification patches: none. The scaffold's README template claims every property is a harness, which this crate cannot say. The pure functions are a cheap proof: for everysizeup toLARGESTandalignup toGRID,class_bytes(class(size, align))is at leastsizeand undersize + GRID, and the index is underCLASSES. Also,heap_layout(l)keepsl's alignment, is never empty and is never smaller thanl. A bounded model ofputandtakeover a fixed arena proves the count never passesDEPTH,cached_bytesis the sum, andtakereturns the lastput(the stack discipline theFreelink encodes). Change: those three harnesses with their falsification patches, in averificationmodule as the sibling crates lay it out. The README's proof section then separates what the harnesses prove from what the heap walk tests. Door: two-way. Effort: M. -
The code relies on the
Freelink's alignment and does not assert it. Finding:const _: () = assert!(size_of::<Free>() <= GRID)(src/lib.rsline 119) checks the size.putcasts the block to*mut Freeunder#[allow(clippy::cast_ptr_alignment)]with the comment thatGRIDalignment "is at least aFree's" (src/lib.rslines 177 to 179). True on every target the crate builds for, and a one-linealign_of::<Free>() <= GRIDbeside the size assertion makes it a mechanism rather than a comment. Change: that assertion. Door: two-way. Effort: S.