enthought / enthought/apptools

StatePickler cache is broken: can result in data corruption

Open
#66 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
38
Forks
21
PR merge metrics
No merged PRs in 30d

Description

The `StatePickler` uses the hash function `hash` to generate a key for its object cache, at least for hashable objects. Without an extra equality check, this is broken, and leads to different objects with the same hash being treated as the same object.

Example failure resulting from this:

```
>>> from apptools.persistence.state_pickler import *
>>> loads_state(dumps([(-1, -1), (-2, -2), (-3, -3)]))
[(-1, -1), (-1, -1), (-3, -3)]
```

Here the error occurs because the tuples `(-1, -1)` and `(-2, -2)` have the same hash.

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.