Skip to content

AOD: fixe memory leak + allow overwriting metadata#7739

Merged
ktf merged 2 commits intoAliceO2Group:devfrom
shahor02:pr_aodfix
Nov 25, 2021
Merged

AOD: fixe memory leak + allow overwriting metadata#7739
ktf merged 2 commits intoAliceO2Group:devfrom
shahor02:pr_aodfix

Conversation

@shahor02
Copy link
Copy Markdown
Collaborator

No description provided.

@shahor02 shahor02 requested review from a team as code owners November 25, 2021 13:42
Comment thread Framework/Core/src/CommonDataProcessors.cxx Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOGP(warnING, "The table \"{}\" is not valid and will not be saved!", tableName);
LOGP(warning, "The table \"{}\" is not valid and will not be saved!", tableName);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the problem here? ta2tr does not seem to be a pointer. Is this deleting an object returned by process() which is not owned by ta2tr? This looks a bit awkward.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TableToTree returns the pointer to the tree after the writing. It has only a default constructor, so although it has a pointer data member, it is not deleted. The alternative would be to define it as unique_ptr, but then its potential consumer should be aware of this.

@jgrosseo
Copy link
Copy Markdown
Collaborator

Hi Ruben,
Why we need the case of overwriting the metadata?

@shahor02
Copy link
Copy Markdown
Collaborator Author

@jgrosseo because currently, it produces FATAL when metadata is there

@jgrosseo
Copy link
Copy Markdown
Collaborator

@jgrosseo because currently, it produces FATAL when metadata is there

Yes, that is not good of course. I would simply change that to WARNING then. The overwrite does not harm, but does not help either...

@shahor02
Copy link
Copy Markdown
Collaborator Author

@jgrosseo do you want simply skip creating the metada if it is already there?

@shahor02
Copy link
Copy Markdown
Collaborator Author

@sawenzel @ktf I've changed the raw mTree pointer in the TableToTree to shared one and removed the deletion of the returned pointer.

@ktf
Copy link
Copy Markdown
Member

ktf commented Nov 25, 2021

@shahor02 i would actually check if we cannot simply avoid returning the tree.

@jgrosseo
Copy link
Copy Markdown
Collaborator

@jgrosseo do you want simply skip creating the metada if it is already there?

Yes, exactly. It will be identical (unless we have a quite bad setup...)

@shahor02
Copy link
Copy Markdown
Collaborator Author

@ktf check with whom? At the moment the returned pointer is never used, but I understood the returning was done on purpose in case somebody will need this pointer.

@shahor02
Copy link
Copy Markdown
Collaborator Author

@jgrosseo ok, I've changed the code to preserve the existing one

@ktf
Copy link
Copy Markdown
Member

ktf commented Nov 25, 2021

@shahor02 what i meant is that the pointer might have been used, so before changing it to anything else, we should have checked. If it's not used, I would be in favour of simply deleting the object inside the function and not return anything.

@shahor02
Copy link
Copy Markdown
Collaborator Author

Hi @ktf, currently the pointer is not used in any real code, but is used in the test:

auto br = (TBranch*)t2->GetBranch("ok");
BOOST_REQUIRE_EQUAL(t2->GetEntries(), ndp);
BOOST_REQUIRE_EQUAL(br->GetEntries(), ndp);
br = (TBranch*)t2->GetBranch("tests");
BOOST_REQUIRE_EQUAL(br->GetEntries(), ndp);

Let me know if you want to preserve it.
In any case, to have this fix in the nightly, I would merge this PR once the CIs are green, then, if decided, can avoid returning a pointer and implement a destructor.

@ktf
Copy link
Copy Markdown
Member

ktf commented Nov 25, 2021

yeah... I guess the correct thing is to return a unique ptr, then. We can merge this and think about it later.

@ktf ktf merged commit 5918d40 into AliceO2Group:dev Nov 25, 2021
@shahor02
Copy link
Copy Markdown
Collaborator Author

yeah... I guess the correct thing is to return a unique ptr, then. We can merge this and think about it later.

For the record: at the moment it returns shared ptr, which is destroyed since never assigned.

@ktf
Copy link
Copy Markdown
Member

ktf commented Nov 25, 2021

Yes, sure, that would work as well. I guess the unique_ptr is maybe better / safer, but we can always change it later.

@shahor02 shahor02 deleted the pr_aodfix branch November 25, 2021 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants