Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flat hash map MixingHashState::kSeed broken when build windows shared lib #1230

Closed
Lingfeng-Sun opened this issue Jul 25, 2022 · 1 comment
Closed
Labels

Comments

@Lingfeng-Sun
Copy link

Describe the bug

When building windows shared libaray(dll), each dll has their own version of kSeed with different value which cause
static size_t hash(T value) { return static_cast<size_t>(Mix(Seed(), static_cast<uint64_t>(value))); }
return different hash value for the same key for each dll and failed.

Steps to reproduce the bug

Say you have A.dll and B.dll both link to absl, and B.dll dpendent on A.dll
In A.dll you have something like
class SingletonA
{
static SingletonA* Inst()
{
static SingletonA* sInstance = new SingletonA();
}

   SingletonA(){ gTestMap.emplace(100, someObject)};
   absl::flat_hash_map<int, void*> gTestMap;

}

In B.dll you'll get
SingletonA.Inst().gTestMap.find(100) == SingletonA.Inst().gTestMap.end()

What version of Abseil are you using?
latest, 2022.7.25

What operating system and version are you using
windows 10

What compiler and version are you using?

vs2022 with Platform toolset Visual Studio 2019 (v142) c++17 enable

What build system are you using?

cmake 3.23.2

@derekmauro
Copy link
Member

We state this in the documentation:

// `absl::Hash` may also produce different values from different dynamically
// loaded libraries. For this reason, `absl::Hash` values must never cross
// boundries in dynamically loaded libraries (including when used in types like
// hash containers.)

We don't have any plans on addressing this.

@derekmauro derekmauro closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants