バグ #2138
Windows版でComponentObserverが動作しない
100%
説明
Windows版でComponentObserverが動作しない
関係しているリビジョン
リビジョン 2142
(差分)
リビジョン 2142
(差分)
The problem that ComponentObserver cannot be used in Windows envrionment
has been fixed. IDL compiler option and definition has been changed.
SdoServiceConsumerBase's virtual dtor has been added. refs #2138
履歴
#1 n-ando がほぼ13年前に更新
- 進捗率 を 0 から 30 に変更
- omniORBのスタブ生成、コンパイル時に、シンボルの扱いに気を付ける必要がある。
http://omniorb.sourceforge.net/omni41/omniORB/omniORB012.html
ComponentObserver.idl はSDOPackage.idl をインクルードしているので、SDOPackageのシンボルに対してはUSE_stub_in_nt_dllを有効にしてシンボル等をimportする必要がある。一方ComponentObserver.idlで定義されているシンボルはUSE_stub_in_nt_dllを無効にする必要がある。
- omniidl のオプションに -Wbdll_includes を付ける。
- INCLUDED_stub_in_nt_dll をプリプロセッサで定義する
これにより、シンボルの参照が正しく行われるようになった。
#3 n-ando がほぼ13年前に更新
- coil::Factory, coil::Singleton にDLL_PLUGINマクロ(dllexport/dllimpoerを切り替える)を追加
- explicit instantiation をする以下の1行をSdoServiceAdminに追加
template class DLL_PLUGIN ::coil::GlobalFactory< ::RTC::SdoServiceConsumerBase >;
効果なし。
dumpbin /EXPORTS rtc110d.dll |grep addFactory|grep SdoService
とやっても何もなし。Factory関係の関数がexportされていない。
#4 n-ando がほぼ13年前に更新
Factoryの実体化のために実際にSdoServiceConsumerのファクトリを使用するダミーコードを追加。
class DummySdoService : public RTC::SdoServiceConsumerBase { public: virtual bool init(RTC::RTObject_impl& rtobj, const SDOPackage::ServiceProfile& profile){ return true;} virtual bool reinit(const SDOPackage::ServiceProfile& profile) {return true;} virtual const SDOPackage::ServiceProfile& getProfile() const { return SDOPackage::ServiceProfile(); } virtual void finalize() {} }; void DummySdoServiceInit() { RTC::SdoServiceConsumerFactory& factory = RTC::SdoServiceConsumerFactory::instance(); factory.addFactory("dummy", ::coil::Creator< ::RTC::SdoServiceConsumerBase, DummySdoService>, ::coil::Destructor< ::RTC::SdoServiceConsumerBase, DummySdoService>); factory.removeFactory("dummy"); std::cout << "DummySdoServiceInit()" << std::endl; }
とりあえず、関数はexportsされている。
H:\work\trunk\OpenRTM-aist\win32\OpenRTM-aist\bin>dumpbin /EXPORTS RTC110d.dll | grep addFactory|grep SdoService 8489 2128 0016FA67 ?addFactory@?$Factory@VSdoServiceConsumerBase@RTC@@V?$ basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@V?$basic_stri ng@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@4@P6APAV12@XZP6AXAAPAV12@@Z@co il@@QAE?AW4ReturnCode@12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D @2@@std@@P6APAVSdoServiceConsumerBase@RTC@@XZP6AXAAPAV67@@Z@Z = @ILT+31330(?addF actory@?$Factory@VSdoServiceConsumerBase@RTC@@V?$basic_string@DU?$char_traits@D@ std@@V?$allocator@D@2@@std@@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$al locator@D@2@@std@@@4@P6APAV12@XZP6AXAAPAV12@@Z@coil@@QAE?AW4ReturnCode@12@ABV?$b asic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@P6APAVSdoServiceConsum erBase@RTC@@XZP6AXAAPAV67@@Z@Z)
#5 n-ando がほぼ13年前に更新
- 進捗率 を 30 から 50 に変更
実験
void DummySdoServiceInit() { RTC::SdoServiceConsumerFactory& factory = RTC::SdoServiceConsumerFactory::instance(); // ここから factory.addFactory("dummy", ::coil::Creator< ::RTC::SdoServiceConsumerBase, DummySdoService>, ::coil::Destructor< ::RTC::SdoServiceConsumerBase, DummySdoService>); factory.removeFactory("dummy"); std::cout << "DummySdoServiceInit()" << std::endl; // ここまで }
- ここから・ここまでをコメントイン: addfactoryのExportシンボルあり
- ここから・ここまでをコメントアウト: addfactoryのExportシンボルなし
使用した関数のみ実体化されそれらがexportされる。
また、template class DLL_PLUGIN ::coil::GlobalFactory< ::RTC::SdoServiceConsumerBase >;
を削除したが、関数はExportされる。RTC.DLLはdumpbinでシンボルを引っ張り出して
すべてのシンボルをexportしているので関係ないみたい。
#6 n-ando がほぼ13年前に更新
- ステータス を 新規 から 終了 に変更
- 進捗率 を 50 から 100 に変更
- DummySdoServiceInit() は不要なことが判明
- INCLUDE_stub_nt_dll と -Wbdll_include を追加
- SdoServiceConsumerBaseのvirtualデストラクタが抜けていたため、オブジェクトが解体されずタイマー等が動き続け落ちていた(Observer削除時)
- explicit instantiation は必要、EXTERNも追加しヘッダに記載
EXTERN template class DLL_PLUGIN ::coil::GlobalFactory< ::RTC::SdoServiceConsumerBase >;
以上でほぼ落ちなくなったので解決とする。
The problem that ComponentObserver cannot be used in Windows envrionment
has been fixed. IDL compiler option and definition has been changed.
SdoServiceConsumerBase's virtual dtor has been added. refs #2138