Skip to content

TTree::Delete() leaves outlying fEND pointer #19457

Description

@jblomer

Check duplicate issues.

  • Checked for duplicates

Description

When deleting a tree from a file, the resulting file is slightly corrupt. It goes usually unnoticed because TFile::Recover() cleans up.

Reproducer

The following script creates a file that on reopen triggers recovery. According to a preliminary analysis, the error occurs when the free segment list is written.

void test()
{
    auto f = TFile::Open("t.root", "RECREATE");
    auto t = new TTree("t", "");
    f->Write();
    f->Close();
    delete f;

    f = TFile::Open("t.root", "UPDATE");
    t = f->Get<TTree>("t");
    t->Delete("all");
    f->Write();
    f->Close();
    delete f;
}

Map of the resulting file:

20250724/165917  At:100    N=118       TFile                     
20250724/165917  At:218    N=49        KeysList                  
20250724/165917  At:267    N=65        FreeSegments              
Address = 332	Nbytes = -136	=====G A P===========
20250724/165917  At:468    N=4075      StreamerInfo   CX =  3.09 
Address = 4543	Nbytes = -1999995458	=====G A P===========
19950000/000000  At:4598   N=1         END 

Map of the file after the new keys list was written (after TDirectoryFile::Close()) but before the new free list was written:

20250724/164705  At:100    N=148       TFile                     
20250724/164935  At:248    N=64        KeysList                  
Address = 312	Nbytes = -363	=====G A P===========
20250724/164705  At:675    N=4646      StreamerInfo   CX =  3.05 
Address = 5321	Nbytes = -100	=====G A P===========
20250724/164705  At:5421   N=70        FreeSegments              
20250724/164705  At:5491   N=1         END

ROOT version

master

Installation method

from sources

Operating system

n/a

Additional context

Found while working on #19251

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions