Skip to content

Review and improve HashMap's handling of an empty table #53853

Closed

Description

@RalfJung

In #53804, I fixed the most immediate problem arising from how HashMap handles the empty table, but @gnzlbg still (rightly) sees more problems. We still use 1 instead of NonNull::dangling() as value for EMPTY, and ptr() even tests equality with EMPTY to return NULL instead. We can't really use non-NULL pointers as sentinel values like that, and NULL is often a worse choice than an aligned dangling pointer because the latter are at least valid for zero-sized operations.

See here for @gnzlbg's suggestions.

Activity

  1. Mark-Simulacrum commented on Dec 23, 2019

    @Mark-Simulacrum
    Member

    I'm going to close this issue since our hash maps are now a thin wrapper around hashbrown which hopefully doesn't suffer from these issues; if it does, this should be refiled upstream. A cursory examination didn't find any obvious problems for sentinel use of dangling or so.

  2. gnzlbg commented on Dec 24, 2019

    @gnzlbg
    Contributor

    Yes none of this applies to the new hashbrown impl. cc @Amanieu in case they want to re-read the comments and any of that rings a bell, but I haven't see anything like that in hashbrown.

  3. Amanieu commented on Dec 24, 2019

    @Amanieu
    Member

    I agree, I don't think any of this applies to hashbrown.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions