py-evm icon indicating copy to clipboard operation
py-evm copied to clipboard

fix: make KeyMapDB deep-copiable

Open charles-cooper opened this issue 2 years ago • 2 comments

What was wrong?

KeyMapDB would segfault on deepcopy, due to recursion in __getattr__

How was it fixed?

Todo:

  • [ ] Clean up commit history

  • [ ] Add or update documentation related to these changes

  • [ ] Add entry to the release notes

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

charles-cooper avatar Jun 13 '23 08:06 charles-cooper

Sorry we never responded to this one. Do you have a way we can reproduce or do you mind writing a test case?

kclowes avatar Jul 20 '23 19:07 kclowes

sure, you can reproduce just by creating an instance of KeyMapDB and trying to copy it.

In [1]: from eth.db.backends.memory import MemoryDB

In [2]: from eth.db.hash_trie import HashTrie

In [3]: t = HashTrie(MemoryDB({}))

In [4]: import copy

In [5]: copy.copy(t)
Segmentation fault (core dumped)

i'm guessing that KeyMapDB.__getattr__ is never actually used, otherwise the segfault would have been noticed before

charles-cooper avatar Jul 20 '23 20:07 charles-cooper