Skip to content

Miri failure in btree::map::test_iter_min_max test #73915

Closed

Description

btree::map::test_iter_min_max recently started failing in Miri:

error: Undefined Behavior: not granting access to tag <untagged> because incompatible item is protected: [Unique for <26146034> (call 7514376)]

   --> /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/libcore/ptr/non_null.rs:121:9

    |

121 |         &*self.as_ptr()

    |         ^^^^^^^^^^^^^^^ not granting access to tag <untagged> because incompatible item is protected: [Unique for <26146034> (call 7514376)]

    |

    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental

    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

            

    = note: inside `std::ptr::NonNull::<alloc::collections::btree::node::LeafNode<i32, i32>>::as_ref` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/libcore/ptr/non_null.rs:121:9

    = note: inside `alloc::collections::btree::node::NodeRef::<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::LeafOrInternal>::as_leaf` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/node.rs:321:18

    = note: inside `alloc::collections::btree::node::NodeRef::<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::LeafOrInternal>::len` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/node.rs:293:9

    = note: inside `alloc::collections::btree::node::Handle::<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::LeafOrInternal>, alloc::collections::btree::node::marker::Edge>::new_edge` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/node.rs:802:30

    = note: inside `alloc::collections::btree::node::Handle::<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::Leaf>, alloc::collections::btree::node::marker::Edge>::forget_node_type` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/node.rs:1361:18

    = note: inside `alloc::collections::btree::navigate::<impl alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::Leaf>, alloc::collections::btree::node::marker::Edge>>::next_kv` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/navigate.rs:16:24

    = note: inside closure at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/navigate.rs:132:26

    = note: inside `alloc::collections::btree::navigate::replace::<alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::Leaf>, alloc::collections::btree::node::marker::Edge>, alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::LeafOrInternal>, alloc::collections::btree::node::marker::KV>, [closure@alloc::collections::btree::navigate::<impl alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut<'a>, K, V, alloc::collections::btree::node::marker::Leaf>, alloc::collections::btree::node::marker::Edge>>::next_unchecked::{{closure}}#0]>` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/navigate.rs:88:28

    = note: inside `alloc::collections::btree::navigate::<impl alloc::collections::btree::node::Handle<alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Mut, i32, i32, alloc::collections::btree::node::marker::Leaf>, alloc::collections::btree::node::marker::Edge>>::next_unchecked` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/navigate.rs:131:22

    = note: inside `std::collections::btree_map::RangeMut::<i32, i32>::next_unchecked` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/map.rs:1904:18

    = note: inside `<std::collections::btree_map::IterMut<i32, i32> as std::iter::Iterator>::next` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/map.rs:1457:35

    = note: inside `<std::collections::btree_map::ValuesMut<i32, i32> as std::iter::Iterator>::next` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/liballoc/collections/btree/map.rs:1810:9

    = note: inside `<std::collections::btree_map::ValuesMut<i32, i32> as std::iter::Iterator>::fold::<&mut i32, [closure@std::iter::Iterator::min_by::fold::{{closure}}#0 0:for<'r, 's> fn(&'r &mut i32, &'s &mut i32) -> std::cmp::Ordering {<&mut i32 as std::cmp::Ord>::cmp}]>` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/libcore/iter/traits/iterator.rs:2021:29

    = note: inside `<std::collections::btree_map::ValuesMut<i32, i32> as std::iter::Iterator>::fold_first::<[closure@std::iter::Iterator::min_by::fold::{{closure}}#0 0:for<'r, 's> fn(&'r &mut i32, &'s &mut i32) -> std::cmp::Ordering {<&mut i32 as std::cmp::Ord>::cmp}]>` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/libcore/iter/traits/iterator.rs:2061:14

    = note: inside `<std::collections::btree_map::ValuesMut<i32, i32> as std::iter::Iterator>::min_by::<for<'r, 's> fn(&'r &mut i32, &'s &mut i32) -> std::cmp::Ordering {<&mut i32 as std::cmp::Ord>::cmp}>` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/libcore/iter/traits/iterator.rs:2627:9

    = note: inside `<std::collections::btree_map::ValuesMut<i32, i32> as std::iter::Iterator>::min` at /home/travis/build/RalfJung/miri-test-libstd/rust-src-patched/src/libcore/iter/traits/iterator.rs:2499:9

note: inside `btree::map::test_iter_min_max` at alloc_miri_test/../liballoc/tests/btree/map.rs:343:16

   --> alloc_miri_test/../liballoc/tests/btree/map.rs:343:16

    |

343 |     assert_eq!(a.values_mut().min(), Some(&mut 24));

    |                ^^^^^^^^^^^^^^^^^^^^

note: inside closure at alloc_miri_test/../liballoc/tests/btree/map.rs:313:1

   --> alloc_miri_test/../liballoc/tests/btree/map.rs:313:1

    |

313 | / fn test_iter_min_max() {

314 | |     let mut a = BTreeMap::new();

315 | |     assert_eq!(a.iter().min(), None);

316 | |     assert_eq!(a.iter().max(), None);

...   |

344 | |     assert_eq!(a.values_mut().max(), Some(&mut 42));

345 | | }

    | |_^

(Sorry for the bad spacing, Travis logs are like that...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collection`C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions