I have some classes which are derived from TH2Poly. I store them in a file and want to read them back in. I do this by creating a TList* via GetListOfKeys() from the TDirectory and looping over the keys. I then call key->ReadObj() to read the objects and cast them to the appropriate type. Before I check via InheritsFrom if it's the correct type. The problem I see is that when I call the ReadObj() method, the Streamer() method of the object is called via TKey and subsequently TBufferFile::ReadClassBuffer() of the generated dictionary. At some point after many other function calls TStreamerInfo calls TClass::DeleteArray() issuing TList::Clear() and the output is flooded with error messages like this:
ROOT<TList::Clear>: A list is accessing an object (0x<random_memory_address>) already deleted (list name = TList)
And sometimes the code eventually segfaults when TCollection::GarbageCollect() is called with a null pointer.
The problem might have been introduced with ROOT6. I do not see any issue with the latest ROOT5 version on git, there everything works as intended. I checked it with a 6.12 release and a 6.15 development version, in both cases I get the error messages and occasionally a segfault.
A minimal (not) working example is attached. A version which is not derived but does exactly the same is attached as well, this works as intended with all ROOT versions I checked. If I try to do the same with TH2D everything works as well. It seems to be related to derived classes from TH2Poly somehow.