Skip to content

Map lifetime bugs: stale finalizers delete new entries; edges never pruned; rename keeps both names #274

@rozyczko

Description

@rozyczko

Findings G-H5, G-M10, V-M8 in DEEP_ANALYSIS.md (parent #261).

src/easyscience/global_object/map.py:

  • G-H5 (lines 164-178, 218-220): add_vertex deletes a stale __type_dict entry on name reuse but never detaches the old object's finalizer; prune_type_dict deletes by name only, so when the old object is later collected it silently removes the new object's type/adjacency entry. Map._clear() (lines 326-334) clears dicts without detaching finalizers — heavily used in tests, so cross-test contamination is realistic.
  • G-M10 (lines 180-184, 218-220): edges to collected objects are never pruned — adjacency lists keep dangling names; classTools.generatePath then crashes on get_item_by_key.
  • V-M8 (descriptor_base.py:266-269, new_base.py:83-87, based_base.py:94-97): unique_name setters assign before validating; on collision the object claims a name the map attributes to a different object. Renaming also registers the new name without removing the old — object registered under both names with two live finalizers.

Fix: detach finalizers on re-registration and in _clear(); have finalizers verify identity (name -> expected ref) before pruning; prune inbound edges on removal; validate-then-assign in the setters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [area] global_objectAnything related to the global_object[priority] highShould be prioritized soon[scope] bugBug report or fix (major.minor.PATCH)
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions