Skip to content

Commit 77368be

Browse files
docs: the shared-address check's TOCTOU window is named at both sites
CodeRabbit's atomicity finding on the reap: the snapshot check races a concurrent identical-content write. The port has no conditional delete, and adding one is exactly the label-scoped-delete work item already filed as #1300 — which closes the window by construction at every backend instead of per-call-site. Deferred there, named here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent f999917 commit 77368be

8 files changed

Lines changed: 102 additions & 308 deletions

File tree

core/src/store/namespace_store/events.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,10 @@ fn vec_to_bytes(v: &[f32]) -> Vec<u8> {
465465
}
466466

467467
fn bytes_to_vec(bytes: &[u8]) -> Vec<f32> {
468-
bytes
469-
.chunks_exact(4)
470-
.map(|chunk| f32::from_le_bytes([chunk[0], chunk[1], chunk[2], chunk[3]]))
468+
let (chunks, _remainder) = bytes.as_chunks::<4>();
469+
chunks
470+
.iter()
471+
.map(|chunk| f32::from_le_bytes(*chunk))
471472
.collect()
472473
}
473474

core/src/store/namespace_store/helpers.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ impl UnifiedMemory {
5656
}
5757

5858
pub(crate) fn bytes_to_vec(bytes: &[u8]) -> Vec<f32> {
59-
bytes
60-
.chunks_exact(4)
61-
.map(|chunk| {
62-
let arr: [u8; 4] = chunk.try_into().unwrap_or([0; 4]);
63-
f32::from_le_bytes(arr)
64-
})
59+
let (chunks, _remainder) = bytes.as_chunks::<4>();
60+
chunks
61+
.iter()
62+
.map(|chunk| f32::from_le_bytes(*chunk))
6563
.collect()
6664
}
6765

core/src/store/namespace_store/segments.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,10 @@ fn vec_to_bytes(v: &[f32]) -> Vec<u8> {
600600
}
601601

602602
fn bytes_to_vec(bytes: &[u8]) -> Vec<f32> {
603-
bytes
604-
.chunks_exact(4)
605-
.map(|chunk| f32::from_le_bytes([chunk[0], chunk[1], chunk[2], chunk[3]]))
603+
let (chunks, _remainder) = bytes.as_chunks::<4>();
604+
chunks
605+
.iter()
606+
.map(|chunk| f32::from_le_bytes(*chunk))
606607
.collect()
607608
}
608609

core/src/tree/score/embed/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,8 @@ pub fn unpack_embedding(b: &[u8]) -> Result<Vec<f32>> {
313313
b.len()
314314
);
315315
}
316-
let floats: Vec<f32> = b
317-
.chunks_exact(4)
318-
.map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]]))
319-
.collect();
316+
let (chunks, _remainder) = b.as_chunks::<4>();
317+
let floats: Vec<f32> = chunks.iter().map(|c| f32::from_le_bytes(*c)).collect();
320318
if floats.len() != EMBEDDING_DIM {
321319
anyhow::bail!(
322320
"embedding blob length {} floats, expected {}",

0 commit comments

Comments
 (0)