My understanding is that:

  1. root garbage collector is using a static global object because otherwise we would not see it in __cxa_finalize
  2. the root garbage collector and the DefaultEnv are not in the same translation unit
  3. the order in which translation units are initialized / deinitialized is not defined / guaranteed
  4. hence if you lucky it works if you not it segfaults

(Feel free to share other explanation! ;-)

Now the proposed solution:
1. the initializer object has been moved to the header file, this means that every translation unit that uses DefaultEnv will have an initializer object
2. the initializer has an instance counter so we can initialize the DefaultEnv only when the first initializer is being created and finalize it when the last one is being destroyed
3. also the DefaultEnv source file includes the DefaultEnv header file so this translation unit will also have an initializer object (as before) so for sure the lifetime of the DefaultEnv wont be shorter than it was before, in particular I don't see why it would be related to the fact that there are some / or there aren't any objects using the environment ;-)

Anyway, I think it's worth trying it out ;-)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.



Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1