wesom 发表于 2012-3-28 14:03:12

不同gcc版本下动态卸载的问题

同一份源码,在ubuntu 10.04下gcc4.4.3下运行良好
在ubuntu 11.04下gcc4.5.2下,报这个错
Inconsistency detected by ld.so: dl-close.c: 719: _dl_close: Assertion `map->l_init_called' failed!
我查了下,使用ACE Service Configurator框架,动态卸载xxx.so库时报这个错,而其他三方库完全是一样的
难道是编译器不同会导致这个问题?

winston 发表于 2012-3-28 16:37:51

在两个机器上重新编译过ACE和你自己的代码没有?还是copy过来的?

wesom 发表于 2012-3-28 18:13:44

copy和重编译都试过,一样的现象
不过我调试了下,可以大概确认是ACE_Unmanaged_Singleton类模板导出编译导致的问题,代码中注释
ACE_Unmanaged_Singleton<xxx,xxx>::instance()->xxx()后就没这个问题,如果不注释程序运行也良好,只是卸载so库时一定会报那个错。估计是加载so库时就没找到export出来的函数,未完全初始成功。但不知道怎么解决。。。
查了下config-g++-common.h中有这样一段,没搞明白
#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
// Sadly, G++ 4.x silently ignores visibility attributes on
// template instantiations, which breaks singletons.
// As a workaround, we use the GCC visibility pragmas.
// And to make them fit in a macro, we use C99's _Pragma()
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470
// This has been fixed in GCC 4.1.1 with FC6 but not with SuSE 10.2
// that gets shipped with GCC 4.1.2 so we assume that with GCC 4.2
// this will be fixed on the head. With FC6 just set this define yourself
#   ifndef ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS
#   define ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1
#   endif
#endif
页: [1]
查看完整版本: 不同gcc版本下动态卸载的问题