ekmett / ekmett/intern

Is this library safe?

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
25
Forks
8
PR merge metrics
No merged PRs in 30d

Description

I usually blindly trust anything with the name kmett attached, but I'm experiencing some behavior where distinct interned values come back with the same `Id`. I can verify that they belong to the same cache bucket (i.e. their modulus is the same wrt the `cacheWidth`) and that they have distinct hashes.

The setup for my work is open source but it's quite involved. I can share code if needed but looking for a high level answer first. I'm not an `unsafePerformIO` guru, but under what conditions is using `intern` safe? Are race conditions possible? Can compiler optimizations effect the outcome?

In fact, since this whole thing is predicated based on unique `Int` hashes, why have this `Id` be some formulaic incremented value instead of just using `hash . describe` ?

NOTE: When I stop using the [formula](https://github.com/ekmett/intern/blob/master/Data/Interned/Internal.hs#L89) based on current cache state for the `Id` and instead switch to `hash . describe` I dont have any more problems

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.