Skip to content

[libc++] _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY for hashtable-based containers? #102303

Open
@olologin

Description

Hi, in a project that I work on I see a lot of code that implicitly depends on order of elements in hashtable-based containers (unordered_set/map/multimap).

What if we shake order of elements in hashtable based on compile define like _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY which is shaking sorting inputs now?
Maybe we can wrap hash function if such compile definition is used, and combine original hash with random (but fixed at process start) seed to produce different results, which will in turn produce different order of elements in hashtable.

I expect that can help us to find places that have bad dependency on element order.

Is this a good idea? Anyone else finds this potentially useful?

Metadata

Assignees

No one assigned

    Labels

    enhancementImproving things as opposed to bug fixing, e.g. new or missing featurehardeningIssues related to the hardening effortlibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions