Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JFactoryPodioT: only delete shallow object in ClearData #243

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

veprbl
Copy link
Contributor

@veprbl veprbl commented Oct 2, 2023

Resolves #241

@nathanwbrei
Copy link
Collaborator

I like this approach! Is this enough to make the heisenbug go away? I was a little worried that one of us would have to find a way to enforce that the podio::Frame gets deleted after all of the other mDatas.

@nathanwbrei nathanwbrei merged commit ab7069e into JeffersonLab:master Oct 2, 2023
3 checks passed
@veprbl
Copy link
Contributor Author

veprbl commented Oct 3, 2023

I think there is a small caveat here. I was focused on saving the case when mData is populated from objects managed by a collection, and did not appreciate that JANA in principle suggests that Set<> methods can be used too (which we don't do in EICrecon anymore). If it will be used, that would lead to a memory leak because of the unlink(). What is dubious to me is if an extended fix would have to account for the fact that Set/SetCollection append items to mData and not just sets them.

@nathanwbrei
Copy link
Collaborator

Set<> methods don't allow appending on PODIO objects because PODIO collections don't allow it once they've been added to the frame. One reason the code looks so weird is because the PODIO objects go through the exact same procedure, regardless of whether the user adds them to a collection themselves and calls SetCollection(), or calls Set<> and lets JANA do it behind the scenes. (Yes, the difference in constraints on Set<> annoys me, but the alternative is far worse)

TLDR; I think calling unlink() should be fine and won't cause a memory leak.

@veprbl
Copy link
Contributor Author

veprbl commented Oct 4, 2023

Set<> methods don't allow appending on PODIO objects because PODIO collections don't allow it once they've been added to the frame.

It appends to mData on subsequent calls:
https://github.com/veprbl/JANA2/blob/fad0866d147913759b50789573066b40eb0abc16/src/libraries/JANA/Podio/JFactoryPodioT.h#L184-L189

And I now see that the implementation of Insert() just ignores mData.

@veprbl
Copy link
Contributor Author

veprbl commented Oct 4, 2023

Or rather Set doesn't append, but SetCollection does. So yeah, that's actually fine, I suppose.

@nathanwbrei
Copy link
Collaborator

Set<>() calls SetCollection(), which will fail on this->mFrame->put(std::move(collection), this->GetTag()); if this is an append. We probably should check that proactively though. Insert<>() forgetting to set mData is a bug though.

wdconinc added a commit to eic/eic-spack that referenced this pull request Oct 5, 2023
### Briefly, what does this PR introduce?
This backports the bugfix patch in
JeffersonLab/JANA2#243 to the 2.1.1 release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PODIO deletion heisenbug
2 participants