# Error in \<THashList::Delete\>: A list is accessing an object (0x47a4ef0) already deleted (list name = THashList)

**URL:** <https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375>\
**Category:** Newbie\
**Tags:** root\
**Created:** [November 4, 2025, 12:00pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375 "2025-11-04T12:00:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 12:00pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/1 "2025-11-04T12:00:28Z")

</div>

* * *

_ROOT Version:_ 6.24.02  
_Platform:_ Alma linux 9.2  
_Compiler:_ gcc 11.5.0-5

Dear experts

I got the error message above when opening the ROOT file in a function:

```auto
void COMET::IRECBE::ReadResponseFile(std::string const& type){
    std::string SIMDETRESPROOT = getenv("SIMDETECTORRESPONSEROOT");
    std::string responseFile = SIMDETRESPROOT+"/parameters/RECBE_response/"+COMET::IOARuntimeParameters::Get().GetParameterS("SimDetectorResponse.RECBE." + type + "ResponseFunctionFileName")+".root";

    //read TDC response function
    COMETNamedLog("IRECBE", "Loading response file: " << responseFile);
    std::unique_ptr<TFile> f_resp{ TFile::Open(responseFile.c_str(), "READ")};
    if(!f_resp){
        std::string msg = "can not find RECBE " + type + " respone file";
        throw std::runtime_error(msg);
    }
    TIter next(f_resp->GetListOfKeys());
    TKey* key;
    while( (key = (TKey*)next()) ){
        TGraph* g_in = dynamic_cast<TGraph*>(key->ReadObj());
        if(g_in){
            std::string graphName = g_in->GetName();
            if(graphName == "g_deadTime"){
                fTDCDeadTime = std::make_shared<TGraph>(*g_in);
            }
            else{
                int const input = std::stoi(graphName.substr(2));
                std::shared_ptr<TGraph> g = std::make_shared<TGraph>(*g_in);

                if(type == "ADC") fADCResponseFunction[input] = g;
                else if(type == "TDC") fTDCResponseFunction[input] = g;
                else COMETNamedError("IRECBE", "Unknown response type: " << type);
            }
        }
    }
    f_resp->Close();
    COMETNamedInfo("IRECBE", "Finished reading response function");
}

```

This function will be called twice and `type` will be different (read different files). When it is called 2nd time I got the error message, many.

Notice that when I directly open the 2nd ROOT file by `root file.root` (I’m sure that root version is the same) I won’t get any error message. Only when the file is opened in this function I will get error messages. Why?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 4, 2025, 12:22pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/2 "2025-11-04T12:22:41Z")

</div>

Do you get this error message at file opening time or later in you code ?

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 2:51pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/3 "2025-11-04T14:51:32Z")

</div>

After checking the output I found this error message occur when processing the line:

```auto
f_resp->Close();

```

Only the second time of calling this fuction (`ReadResponseFile(std::string const& type)`) I get errors.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 4, 2025, 2:55pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/4 "2025-11-04T14:55:50Z")

</div>

Do you get the same error if you supress the code in betwen. Something like:

```auto
void COMET::IRECBE::ReadResponseFile(std::string const& type){
    std::string SIMDETRESPROOT = getenv("SIMDETECTORRESPONSEROOT");
    std::string responseFile = SIMDETRESPROOT+"/parameters/RECBE_response/"+COMET::IOARuntimeParameters::Get().GetParameterS("SimDetectorResponse.RECBE." + type + "ResponseFunctionFileName")+".root";

    //read TDC response function
    COMETNamedLog("IRECBE", "Loading response file: " << responseFile);
    std::unique_ptr<TFile> f_resp{ TFile::Open(responseFile.c_str(), "READ")};
    if(!f_resp){
        std::string msg = "can not find RECBE " + type + " respone file";
        throw std::runtime_error(msg);
    }

    f_resp->Close();
    COMETNamedInfo("IRECBE", "Finished reading response function");
}

```

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 2:57pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/5 "2025-11-04T14:57:46Z")

</div>

No, error messages disappeared.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 4, 2025, 3:04pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/6 "2025-11-04T15:04:18Z")

</div>

So something went wrong in between. Can you identify which piece of code causes the error by reintroducing it step by step until the error appears again? Start with the empty while loop, and so on.

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 3:06pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/7 "2025-11-04T15:06:54Z")

</div>

Yes, I did that and found that if I only use

```auto
if(graphName == "g_deadTime"){
                fTDCDeadTime = std::make_shared<TGraph>(*g_in);
            }

```

But comment out the `else` part, the number of error messages became one. And in my 1st file this `if` will not be processed, in my 2nd file this `if` will only be processed once (only 1 TGraph called `g_deadtime`).

Does this mean something wront with `TGraph* g_in = dynamic_cast<TGraph*>(key->ReadObj());`? Do I need to delete this pointer?

And if I comment out code inside `if(g_in)`part, there is no error message anymore, which means if I only use `dynamic_cast` it doesn’t cause the error

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 3:21pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/8 "2025-11-04T15:21:59Z")

</div>

One thing maybe I need to mention: When I created those 2 ROOT files, I used a newer ROOT version v6.32.04, and for the 1st file I set the `TFile::k630forwardCompatibility` right after `TFile::Open(name, “RECREATE”)`, for the 2nd file I set the `TFile::k630forwardCompatibility` right before the `TFile::Close()` instead of right after opening. Will this cause the error messages?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 4, 2025, 3:23pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/9 "2025-11-04T15:23:19Z")

</div>

May be @pcanal has some idea about it.

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 3:29pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/10 "2025-11-04T15:29:37Z")

</div>

I tried this simple example:

```auto
root [0] TFile* f = TFile::Open("file.root", "READ")
(TFile *) 0x1d97a70
root [1] TGraph* g = (TGraph*)gDirectory->Get("g_50")
(TGraph *) 0x2450340
root [2] std::shared_ptr<TGraph> gg = std::make_shared<TGraph>(*g)
(std::shared_ptr<TGraph> &) std::shared_ptr -> 0x308d510
root [3] f->Close()
Error in <THashList::Delete>: A list is accessing an object (0x2f5d6e0) already deleted (list name = THashList)

```

And error message appeared.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 4, 2025, 3:37pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/11 "2025-11-04T15:37:36Z")

</div>

`std::cout << g->ClassName() << std::endl;`

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 4, 2025, 3:45pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/12 "2025-11-04T15:45:40Z")

</div>

I tried what you suggested with a file I have. I get:

```auto
root [0] TFile* f = TFile::Open("tgraph.root", "READ")
(TFile *) 0x7f965204dd00
root [1] TGraph* g = (TGraph*)gDirectory->Get("g1")
(TGraph *) 0x600002114f00
root [2] std::shared_ptr<TGraph> gg = std::make_shared<TGraph>(*g)
(std::shared_ptr<TGraph> &) std::shared_ptr -> 0x600002d30fd8
root [3] f->Close()
root [4] std::cout << g->ClassName() << std::endl;
TGraph
root [5] 

```

So I do not see the error. Note I added the line suggested by @Wile_E_Coyote and it gives `TGraph`

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 3:53pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/13 "2025-11-04T15:53:08Z")

</div>

```auto
root [0] TFile* f = TFile::Open("RECBE_TDCResponse.root", "READ")
(TFile *) 0x2984870
root [1] TGraph* g = (TGraph*)gDirectory->Get("g_50")
(TGraph *) 0x2fc8640
root [2] std::shared_ptr<TGraph> gg = std::make_shared<TGraph>(*g)
(std::shared_ptr<TGraph> &) std::shared_ptr -> 0x2f27800
root [3] f->Close()
Error in <THashList::Delete>: A list is accessing an object (0x3ab3970) already deleted (list name = THashList)
root [4] std::cout<< g->ClassName() <<std::endl
TGraph
(std::basic_ostream<char, std::char_traits<char> >::__ostream_type &) @0x7f61bda26480
root [5] std::cout<< gg->ClassName() <<std::endl
TGraph
(std::basic_ostream<char, std::char_traits<char> >::__ostream_type &) @0x7f61bda26480
root [6] 

```

Here is what I got.

After I set the `TFile::k630forwardCompatibility` right after creating the 2nd ROOT file (then write `TGraph`s in it) instead of before closing it, this error message disappeared. So it should caused by the compability?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 4, 2025, 3:57pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/14 "2025-11-04T15:57:43Z")

</div>

I see you are using ROOT 6.24. Can you tried with a more recent version ? (I tried with master which is ROOT 6.37)

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 4, 2025, 4:06pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/15 "2025-11-04T16:06:59Z")

</div>

I can use a newer version and it won’t cause the error ——- like I said, it seems a compatibility issue…

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [November 4, 2025, 4:57pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/16 "2025-11-04T16:57:50Z")

</div>

> [@Crisps](#):
>
> After I set the `TFile::k630forwardCompatibility` right after creating the 2nd ROOT file

That is when you should be setting it.

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 5, 2025, 2:08am UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/17 "2025-11-05T02:08:38Z")

</div>

May I also ask that do I need to delete he pointer `g_in` or `key` (in the top code block)? It always confuses me about the ownership when I use ROOT classes…

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [November 5, 2025, 3:17pm UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/18 "2025-11-05T15:17:23Z")

</div>

`key` belongs solely to the TFile.  
`gin` should be deleted.

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [November 6, 2025, 1:26am UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/19 "2025-11-06T01:26:25Z")

</div>

So instead of `std::shared_ptr<TGraph> g = std::make_shared<TGraph>(*g_in)` I can just use `std::shared_ptr<TGraph> g = g_in;` without any crash, am I correct?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [November 6, 2025, 7:44am UTC](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375/20 "2025-11-06T07:44:59Z")

</div>

`std::shared_ptr<TGraph> g(g_in);`

[Next page](https://root-forum.cern.ch/t/error-in-thashlist-delete-a-list-is-accessing-an-object-0x47a4ef0-already-deleted-list-name-thashlist/64375.md?page=2)
