Harden PathMap algebra and serialized layouts#45
Conversation
|
The changes to LineListNode seem to hint at a bug-fix, can you give an explanation of the bug? The test for it is quite impenetrable to me. |
|
The LineListNode change is not fixing a newly observed runtime failure by itself... It is guarding an existing layout invariant... LineListNode is written around a fixed in-memory layout. The key byte capacity is chosen so the node stays at 64 bytes with |
| @@ -1850,7 +1854,12 @@ impl<V: Clone + Send + Sync, A: Allocator, Cf: CoFree<V=V, A=A>, OtherCf: CoFree | |||
| if new_mask > 0 { | |||
| AlgebraicResult::Identity(new_mask) | |||
| } else { | |||
| AlgebraicResult::Element(Self::new(None, self.val().cloned())) | |||
| let val = if val_mask & SELF_IDENT > 0 { | |||
| self.val().cloned() | |||
| } else { | |||
| other.val().cloned() | |||
| }; | |||
| AlgebraicResult::Element(Self::new(None, val)) | |||
| } | |||
| }, | |||
| (AlgebraicResult::Identity(rec_mask), AlgebraicResult::None) => { | |||
| @@ -1864,7 +1873,12 @@ impl<V: Clone + Send + Sync, A: Allocator, Cf: CoFree<V=V, A=A>, OtherCf: CoFree | |||
| if new_mask > 0 { | |||
| AlgebraicResult::Identity(new_mask) | |||
| } else { | |||
| AlgebraicResult::Element(Self::new(self.rec().cloned(), None)) | |||
| let rec = if rec_mask & SELF_IDENT > 0 { | |||
| self.rec().cloned() | |||
| } else { | |||
| other.rec().cloned() | |||
| }; | |||
| AlgebraicResult::Element(Self::new(rec, None)) | |||
There was a problem hiding this comment.
Sorry I meant DenseNode -- i.e. the motivation behind these.
|
ah right, denseNode not linelist... that's the actual fix, sorry. it's in that's only right when the surviving half is identity-to-self. in a commutative op the half can be identity-to-other instead (SELF_IDENT cleared, COUNTER_IDENT set), and then cloning self's half drops the wrong operand's value/child into the node. so the fix reads the bit: the giveaway is the the line 698 hunk in no change for the self-identity case, it only diverges when the surviving half matched other. |
Adds hardening changes without syntax changes or feature additions.
The branch fixes DenseByteNode composite operand selection and adds rejection paths for malformed serialized offsets and invalid line-list node layouts.
Validation:
cargo test --lib --testswith default featuresjscpdon touched filesNote:
cargo test --no-default-featuresstill fails in the upstream baseline path, so it is not used as branch validation.