BTreeMap::iter_mut asserts on coarsely aligned keys #67438
Labels
A-collections
Area: `std::collection`
C-bug
Category: This is a bug.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
thread 'main' panicked at 'assertion failed: mem::size_of::<NodeHeader<K, V>>() == mem::size_of::<NodeHeader<K, V, K>>()', src\liballoc\collections\btree\node.rs:612:13
is the result of this code on playground and elsewhere:There is no problem with ordinary u64 or u128 keys (both have 8 byte alignment on x86), neither on 32-bit nor 64-bit builds.
Removing the assert (or relaxing the
==
to<=
, which then states the obvious) makes everything pass, including testing with miri and including some more tests I wrote.Whether that's the right solution, I can't tell, because I've been trying in vain to understand the changes to the
into_key_slice
function in #56648. All that is clear to me is that the comment "because we did the alignment check above" is misguided and I think this issue proves that. For your entertainment, here are some particular asserts that also succeed on x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc and i686-pc-windows-msvc:The text was updated successfully, but these errors were encountered: