angr/tests/knowledge_plugins/key_definitions
Kevin Phoenix 1b5ef20505
knowledge_plugins, code_location: recompute hashes after unpickling (#6511)
* knowledge_plugins, code_location: recompute hashes after unpickling

Atom, Definition, and CodeLocation cache their hash in a `_hash` slot. The
default pickling persists that slot, but the hash folds in per-process-salted
hashes (e.g. of register-name strings), so a value pickled in one process is
stale when unpickled in another -- equal objects then hash differently, which
breaks sets/dicts (and assertCountEqual) rebuilt from a pickle.

Add `__getstate__`/`__setstate__` that drop `_hash` from the pickled state and
reset it to None on load, so it is recomputed lazily in-process. `__dict__`
and all slots are otherwise preserved, and the existing default-format
pickles still load.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Disable protected-member for hash checks

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 12:06:45 -07:00
..
__init__.py tests: Add missing __init__.py files for test discovery (#3498) 2022-08-29 23:10:42 -07:00
test_atoms.py knowledge_plugins, code_location: recompute hashes after unpickling (#6511) 2026-06-17 12:06:45 -07:00
test_environment.py Enable ruff isort rule (#6452) 2026-06-02 14:48:07 -07:00
test_heap_address.py Enable ruff isort rule (#6452) 2026-06-02 14:48:07 -07:00
test_live_definitions.py Enable ruff isort rule (#6452) 2026-06-02 14:48:07 -07:00