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

Bug #435547 reported by Jacob Holm on 2009-09-23
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Status tracked in 3.9

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.

Jacob Holm (jacobholm) wrote :
Jim Fulton (jim-zope) wrote :

Are you actually using weakrefs?

Jim Fulton (jim-zope) wrote :

Thanks much for the patch and especially the test patch!

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  Edit
Everyone can see this information.

Other bug subscribers