persistent.wref.WeakRef breaks silently on cross-database references

Bug #435547 reported by Jacob Holm
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ZODB
Status tracked in 3.9
3.10
Fix Released
Undecided
Unassigned
3.9
Fix Released
Undecided
Unassigned

Bug Description

The special-casing of persistent.wref.WeakRef in ZODB.serialize does not take multi-databases into account. It assumes that a WeakRef is always to an object in the same database. This means that a WeakRef stored in one database that originally pointed to an object in a different database will either appear as if the object has gone away (bad if it hasn't) or will end up pointing to a completely different object that just accidentally have the same oid (worse).

Fixing this requires changing the format used for storing WeakRefs to allow an optional database name. (Or possibly introducing a new format). See the attached patch for one possible way of doing it.

Revision history for this message
Jacob Holm (jacobholm) wrote :
Revision history for this message
Jim Fulton (jim-zope) wrote :

Are you actually using weakrefs?

Revision history for this message
Jim Fulton (jim-zope) wrote :

Thanks much for the patch and especially the test patch!

Revision history for this message
Jacob Holm (jacobholm) wrote :

I had a use case for weakrefs within the same database, and discovered the issue while trying to figure out how they worked. In fact, the same hobby project where I also discovered issue185066 and issue428039. Unfortunately that code died with my old hard drive about two months ago, so I can't look up what it was right now. I hope to get back to it some day, both because the project was algorithmically interesting, and because it was a good way for me to learn about all the dark corners of the ZODB. Catching and helping to fix a bug or two along the way was a bonus. :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.