Skip to content

LinkedList corrupted in .split_off() #26021

Closed
@bluss

Description

@bluss

User seppo0010 in #rust irc found this corruption and crasher bug in LinkedList::split_off()

Exists in rustc 1.0 and nightly

(playpen link)

use std::collections::LinkedList;

fn main() {
    let mut v1 = LinkedList::new();
    v1.push_front(1u8);
    v1.push_front(1u8);
    v1.push_front(1u8);
    v1.push_front(1u8);
    let _ = v1.split_off(3);
    assert_eq!(v1.len(), 3);
    //assert_eq!(v2.len(), 1);

    println!("{}", v1.iter().len());
    println!("{}", v1.iter().collect::<Vec<_>>().len());
}

Corruption is visible when you let the split off vector drop at once.

It's too late for me to analyze this right now, but I suspect a backlink is not being updated correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-highHigh priorityT-libs-apiRelevant to the library API 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