8000 `concurrent_hash_map` Iterator Construction Allows Duplicate Keys · Issue #1764 · uxlfoundation/oneTBB · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
concurrent_hash_map Iterator Construction Allows Duplicate Keys #1764
Open
@0xSqualo

Description

@0xSqualo

Summary

Initialization of concurrent_hash_map allows duplicate key entries during iterator list construction.

Version

2022.0.0-2

Environment

  • AMD Ryzen 9 7950X3D
  • Ubuntu 25.04
  • 2022.0.0-2

Observed Behavior

Initializing the concurrent_hash_map from an iterator of a non-unique type container (e.g. std::vector<T>) initializes the map with duplicate keys. This does not happen through other initialization / constructor methods.

Expected Behavior

That no duplicate key / value pairs are present or allowed in the concurrent_hash_map, irrespective of construction or post instantiation insertion (internally deduplicated based on insertion ordering as it would be if iterating post construction and inserting via an iterator loop).

Steps To Reproduce

std::vector<std::pair<uint64_t, uint64_t>> x {
        {0, 0},
        {0, 1}, // Enter 0 as a key twice intentionally!
};
oneapi::tbb::concurrent_hash_map<uint64_t, uint64_t> y{ std::begin(x), std::end(x) };

// This prints two values e.g.
    // 0: 1 
    // 0: 0
for (auto const& [key, value] : y) {
    std::cout << key << ": " << value << std::endl;
}
    
// Check that we only have 1 item in the hashmap
if (y.size() != 1) {
    std::cout << "y.size() = " << y.size() << std::endl;
    abort(); // This triggers because the size is 2!
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0