[Bug 902] Type system appears to destroy helper objects after RTT has exited

On Sep 25, 2011, at 12:13 , Peter Soetens wrote:

> http://bugs.orocos.org/show_bug.cgi?id=902
> Peter Soetens <peter [..] ...> changed:
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |peter [..] ...
> --- Comment #5 from Peter Soetens <peter [..] ...> 2011-09-25 18:13:51 CEST ---
> (In reply to comment #2)
>> Created attachment 739 [details]
>> Log from rtstring-test
>> Note the "rt_string_ctor_int() CTOR" and "rt_string_ctor_string() CTOR" lines
>> when the helper objects are created. Note that they are destroyed multiple
>> times, apparently, including _after_ RTT and the TLSF memory pool deallocation.
>> Also note that TLSF indicates that 64 bytes are still deallocated when it is
>> destroyed.
> This bug is easily fixed by adding a static OperatorRepository::Release()
> function which does a reg.reset() call (see Operators.cpp) and then calling
> this Release function in __os_exit (os/startstop.cpp)
> A similar case could be made for the TypeInfo repository, which also only gets
> freed after RTT exited.
> Peter

Works for v2. Patches pushed to my bug902 branch on gitorious (discard the last two patches, that just demonstrate the problem). NB I also had to add Release calls for GlobalService and PluginLoader. Please verify the order that I placed things in.

These are the Instance() calls we cover now in RTT v2

shell$ egrep -R "Instance\(\);" rtt | grep hpp | egrep -v "LocalOp|FactoryMap"
rtt/internal/GlobalEngine.hpp: RTT_API static ExecutionEngine* Instance();
rtt/internal/GlobalService.hpp: RTT_API static Service::shared_ptr Instance();
rtt/os/MainThread.hpp: static ThreadInterface* Instance();
rtt/os/StartStopManager.hpp: static StartStopManager* Instance();
rtt/os/TimeService.hpp: static TimeService* Instance();
rtt/plugin/PluginLoader.hpp: static boost::shared_ptr<PluginLoader> Instance();
rtt/types/GlobalsRepository.hpp: static shared_ptr Instance();
rtt/types/Operators.hpp: static shared_ptr Instance();
rtt/types/TypeInfoRepository.hpp: static shared_ptr Instance();
# along with Logger::Instance(...)

I'll take a look at v1 also, which I really need. Is it the same basic process? Any other considerations?