Skip to content

Possible bug in clone logic #1155

Open

Description

@nikhilwoodruff

Sometimes when cloning a simulation, I've found that the original simulation is inexplicably affected by actions in the cloned simulation. I've seen this for a while but have been unable to generate a MWE, but yesterday I think I found the issue, in this line. When a group population is cloned, it looks like the clone still has access to the original members, which is unchanged.

Activity

  1. added
    level:advancedRequires substantial OpenFisca experience
    kind:fixBugs are defects and failure demand.
    on Oct 19, 2022
  2. bonjourmauko commented on Dec 6, 2022

    @bonjourmauko
    Member

    Thanks @nikhilwoodruff .

    @benjello at first I thought this was a duplicate of #848 , yet reading both issues, it appears like the behaviour described here is intended. Do you confirm?

  3. benjello commented on Dec 7, 2022

    @benjello
    Member

    I think the behaviour expected by @nikhilwoodruff should be enforced.

  4. added a commit that references this issue on Sep 9, 2026
    4d68f7d
  5. Adelagric commented on Sep 9, 2026

    @Adelagric
    Contributor

    Hi! I believe I found the mechanism behind this, and it turned out to be four compounding defects rather than one. @nikhilwoodruff's intuition about members was correct — the cloned group population keeps the original persons as members — but it was only part of the picture:

    1. Holder.clone shares the holder's InMemoryStorage/OnDiskStorage by reference, so any input set, value cached or array deleted through the clone silently alters the original (and can leave it internally inconsistent: fresh input, stale cached results).
    2. GroupPopulation.clone calls holder.clone(self) instead of holder.clone(result), so the clone's group-entity holders are bound to the original population and simulation.
    3. GroupPopulation.clone reuses self.members (your observation).
    4. The clone shares _data_storage_dir, so with a memory_config active, holders lazily created on both sides write their .npy files into the same directory — one simulation reads the other's values, and garbage-collecting either one deletes the other's files.

    I have a minimal reproduction for each, and a PR with a fix and regression tests: #1385.

  6. added 2 commits that reference this issue on Oct 2, 2026
    2e97b42
    70abbea
  7. added a commit that references this issue on Oct 9, 2026
    0245358
  8. added 3 commits that reference this issue on Oct 19, 2026
    eadb093
    0c5b6f8
    3bced49
  9. added a commit that references this issue on Oct 26, 2026
    ee3bd05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:fixBugs are defects and failure demand.level:advancedRequires substantial OpenFisca experience

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions