{"action":"created","issue":{"url":"https://api.github.com/repos/rttrorg/rttr/issues/79","repository_url":"https://api.github.com/repos/rttrorg/rttr","labels_url":"https://api.github.com/repos/rttrorg/rttr/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/rttrorg/rttr/issues/79/comments","events_url":"https://api.github.com/repos/rttrorg/rttr/issues/79/events","html_url":"https://github.com/rttrorg/rttr/issues/79","id":251224478,"number":79,"title":"deregistration","user":{"login":"NuckNuck","id":30586249,"avatar_url":"https://avatars1.githubusercontent.com/u/30586249?v=4","gravatar_id":"","url":"https://api.github.com/users/NuckNuck","html_url":"https://github.com/NuckNuck","followers_url":"https://api.github.com/users/NuckNuck/followers","following_url":"https://api.github.com/users/NuckNuck/following{/other_user}","gists_url":"https://api.github.com/users/NuckNuck/gists{/gist_id}","starred_url":"https://api.github.com/users/NuckNuck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuckNuck/subscriptions","organizations_url":"https://api.github.com/users/NuckNuck/orgs","repos_url":"https://api.github.com/users/NuckNuck/repos","events_url":"https://api.github.com/users/NuckNuck/events{/privacy}","received_events_url":"https://api.github.com/users/NuckNuck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-08-18T12:01:36Z","updated_at":"2017-08-21T05:10:51Z","closed_at":null,"body":"Hi,\r\ni have a application which loads multiple dynamic libraryies, with dlopen. The automatic registration works find so fare. If i close the dynamic loaded library with dlclose, the registered type infos are still registered. During the application shutdown a segfault occurs in the type_database destruction process.\r\n\r\nHere a segfault callstack. **wo::ebs::TBlueprint** is a type from a library which was unloaded with dlclose. Is it possible to deregister the type infos before unloading a library?\r\n\r\nThanks,\r\nBastian\r\n\r\n\r\n`--  0 ??()\r\n\r\n--  1 rttr::detail::method_wrapper<void (**wo::ebs::TBlueprint**::*)(std::shared_ptr<wo::ebs::cmp::IComponent> const&), (rttr::access_levels)0, rttr::detail::default_invoke, rttr::detail::default_args<>, rttr::detail::parameter_infos<rttr::detail::parameter_info_wrapper<std::shared_ptr<wo::ebs::cmp::IComponent> const&, 0ul, rttr::detail::no_param_name, void> >, 0ul>::**~method_wrapper()**() \r\n\r\n--  2 std::default_delete<rttr::detail::method_wrapper_base>::operator()() \r\n\r\n--  3 std::unique_ptr<rttr::detail::method_wrapper_base, std::default_delete<rttr::detail::method_wrapper_base> >::~unique_ptr() \r\n\r\n--  4 rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base>::~class_member() \r\n\r\n--  5 std::_Destroy<rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base> >() \r\n\r\n--  6 std::_Destroy_aux<false>::__destroy<rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base>*>() \r\n\r\n--  7 std::_Destroy<rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base>*>() \r\n\r\n--  8 std::_Destroy<rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base>*, rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base> >() \r\n\r\n--  9 std::vector<rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base>, std::allocator<rttr::detail::type_database::class_member<rttr::detail::method_wrapper_base> > >::~vector() \r\n\r\n-- 10 rttr::detail::type_database::~type_database() \r\n\r\n-- 11 __cxa_finalize() \r\n\r\n-- 12 __do_global_dtors_aux() \r\n\r\n-- 13 ??() \r\n\r\n-- 14 _dl_close_worker() \r\n`\r\n"},"comment":{"url":"https://api.github.com/repos/rttrorg/rttr/issues/comments/323647728","html_url":"https://github.com/rttrorg/rttr/issues/79#issuecomment-323647728","issue_url":"https://api.github.com/repos/rttrorg/rttr/issues/79","id":323647728,"user":{"login":"NuckNuck","id":30586249,"avatar_url":"https://avatars1.githubusercontent.com/u/30586249?v=4","gravatar_id":"","url":"https://api.github.com/users/NuckNuck","html_url":"https://github.com/NuckNuck","followers_url":"https://api.github.com/users/NuckNuck/followers","following_url":"https://api.github.com/users/NuckNuck/following{/other_user}","gists_url":"https://api.github.com/users/NuckNuck/gists{/gist_id}","starred_url":"https://api.github.com/users/NuckNuck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuckNuck/subscriptions","organizations_url":"https://api.github.com/users/NuckNuck/orgs","repos_url":"https://api.github.com/users/NuckNuck/repos","events_url":"https://api.github.com/users/NuckNuck/events{/privacy}","received_events_url":"https://api.github.com/users/NuckNuck/received_events","type":"User","site_admin":false},"created_at":"2017-08-21T05:10:51Z","updated_at":"2017-08-21T05:10:51Z","body":"I could identifiy some steps to fix this:\r\n\r\n1.  rttr::detail::type_database needs deregistration functions for every kind of registered info.\r\n```c++\r\n...\r\nvoid register_method(const type& t, std::unique_ptr<method_wrapper_base> meth);\r\nvoid deregister_method(const type& t, std::unique_ptr<method_wrapper_base> meth);\r\n...\r\n```\r\nThis is the easiest approach because the registration process with **RTTR_REGISTRATION** knows all registered infos.\r\n\r\n2. the registration process needs a lifetime scope.\r\n Currently the **RTTR_REGISTRATION** macro implements a struct (_rttr__auto__register___), wich calls _rttr_auto_register_reflection_function__. The _rttr__auto__register___ struct is the right place to register (constructor) and deregister (destructor) the type infos. To achieve this the _rttr__auto__register___ struct could hold the generated _registration::bind_ objects. The _rttr__auto__register___ constructor could  trigger the registration an the destructor the deregistration. So, the **RTTR_REGISTRATION** could be changed to create an object with a lifetime scope.\r\n```c++\r\nstruct rttr__auto__register__\r\n{\r\n    rttr__auto__register__()\r\n    {\r\n        // registration\r\n    }\r\n    ~rttr__auto__register__()\r\n    {\r\n        // deregistration\r\n    }\r\n};\r\nnamespace\r\n{\r\n    const rttr__auto__register__ typeRegistrationObject;\r\n}\r\n```\r\n\r\nI like your library and I hope my suggestions can help to provide this feature.\r\n\r\nBastian"}}
{"actor":{"display_login":"NuckNuck"}}