Skip to content

Commit 7ae952f

Browse files
committed
Add test checking that we do not create TClass at tear down
1 parent 0bc3abe commit 7ae952f

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

root/meta/tclass/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,9 @@ ROOTTEST_ADD_TEST(tclassStl
111111
OUTREF tclassStl.ref
112112
RUN_SERIAL)
113113

114+
ROOTTEST_ADD_TEST(TClassAtTearDown
115+
MACRO execTClassAtTearDown.C
116+
COPY_TO_BUILDDIR empty.root
117+
OUTREF execTClassAtTearDown.ref)
118+
114119
ROOTTEST_ADD_TESTDIRS()

root/meta/tclass/empty.root

403 Bytes
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "TFile.h"
2+
3+
void execTClassAtTearDown()
4+
{
5+
TFile f("empty.root", "READ");
6+
7+
// Because of this call to exit, even-though the TFile is
8+
// on the stack, it will not be destructed.
9+
// Furthermore, TROOT::CloseFile will not destructed either
10+
// since it is on the stack.
11+
// Subsequently the TFile object will still be on the list of
12+
// files when it is being deleted and thus will need to
13+
// interogate the object *AND* its TClass.
14+
// We setup this exmaple so that at the time `exit` is called
15+
// the `TClass` for `TFile` has not been created yet.
16+
// Consequently, its creation will be asked for during
17+
// the deletion of the list of files ... which is in the
18+
// middle of the tear down ... if a TClass object is created
19+
// at that time, it will use some resources (static tables)
20+
// that have already been tear down, resulting in crashes.
21+
// The new behavior is to sort-of ignore this late request
22+
// and build only a dummy TClass object (which does not
23+
// do any registrations).
24+
exit(0);
25+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)