Skip to content

Is not safe for SegQueue to keep pushing #1149

@zhangzhuang15

Description

@zhangzhuang15

In documentation, it says SegQueue is unbounded queue. Let's assume that we have enough memory(memory is really big); if we use SegQueue, and keep pushing, never pop a value, index of tail will increase to the max value of usize type, unfortunately, we continue to push a value, index will be 0 because of usize wrapping_add method, at this moment, index of tail and index of head will bring a problem: SegQueue is empty in is_empty method of SegQueue ! By the way, in practical, memory is not really big as we assumed, and memory exhaustion will come first, as a result, we never see the problem that SegQueue is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions