Skip to content

Memory leak in TFile::Open with UPDATE mode #21997

@vepadulano

Description

@vepadulano

Check duplicate issues.

  • Checked for duplicates

Description

@ferdymercury found a memory leak in TFile::Open which is only shown when the opening mode is "UPDATE":

==179895== 216 (184 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 5,555 of 6,786
==179895==    at 0x48412AC: operator new(unsigned long) (vg_replace_malloc.c:488)
==179895==    by 0x49AA1FB: TStorage::ObjectAlloc(unsigned long) (TStorage.cxx:292)
==179895==    by 0x4005DD: TObject::operator new(unsigned long) (TObject.h:189)
==179895==    by 0x5026A13: TFile::Recover() (TFile.cxx:2174)
==179895==    by 0x502186B: TFile::Init(bool) (TFile.cxx:869)
==179895==    by 0x501FE9E: TFile::TFile(char const*, char const*, char const*, int) (TFile.cxx:583)
==179895==    by 0x502F668: TFile::Open(char const*, char const*, char const*, int, int) (TFile.cxx:3979)
==179895==    by 0x400545: main (repro_tfile_open.cxx:11)

Reproducer

#include <TFile.h>
#include <memory.h>

int main()
{
	{
		auto f = std::make_unique<TFile>("myfile.root", "recreate");
		f->Write();
	}
	std::unique_ptr<TFile> f;
	f.reset(TFile::Open("myfile.root", "update"));
}

ROOT version

Any

Installation method

Any

Operating system

Any

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions