about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-02-22 14:58:00 +0100
committerGitHub <noreply@github.com>2019-02-22 14:58:00 +0100
commit42b9a046d46ef00ecd3a13135f3cd5d7044218b6 (patch)
tree092c9703b8f21afdeab9eef9ad41d8d3ada14787 /src/rustllvm/RustWrapper.cpp
parent894141b57d5a0072eee07a4918db32bfc187e5bb (diff)
parentf0bef49cf10c19b72b7d025aedb407ab5745c365 (diff)
downloadrust-42b9a046d46ef00ecd3a13135f3cd5d7044218b6.tar.gz
rust-42b9a046d46ef00ecd3a13135f3cd5d7044218b6.zip
Rollup merge of #58431 - RalfJung:btree, r=Mark-Simulacrum
fix overlapping references in BTree

This fixes two kinds of overlapping references in BTree (both found by running the BTree test suite in Miri).

In `into_slices_mut`, we did `k.into_key_slice_mut()` followed by `self.into_val_slice_mut()` (where `k` is a copy of `self`). Calling `into_val_slice_mut` calls `self.len()`, which creates a shared reference to `NodeHeader`, which unfortunately (due to padding) overlaps with the mutable reference returned by `into_key_slice_mut`.  Hence the key slice got (partially) invalidated.  The fix is to avoid creating an `&NodeHeader` after the first slice got created.

In the iterators, we used to first create the references that will be returned, and then perform the walk on the tree.  Walking the tree creates references (such as `&mut InternalNode`) that overlap with all of the keys and values stored in a pointer; in particular, they overlap with the references the iterator will later return. This is fixed by reordering the operations of walking the tree and obtaining the inner references.

The test suite still passes (and it passes in Miri now!), but there is a lot of code here that I do not understand...
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions