最近我将操作系统更新为Xubuntu 13.10。现在,任何使用GNU 4.8.1编译器的C++编译都会崩溃:
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Aborted (core dumped)
我从源代码中删除了任何内容,只使用了一个空的主函数:
#if defined(linux) || defined(__linux)
int main()
{
return 0;
}
#endif
故障存在。我试过Xubuntu 13.10 32位和64位版本。两者都存在故障。GDB报告:
Program received signal SIGABRT, Aborted.
0x00007ffff6c33f77 in __GI_raise (sig=sig@entry=6)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
编辑:
同时,我发现问题是基于我的单例实现的。该实现与MinGW-64在与GCC 4.8和Xubuntu 13.04:的握手中成功工作
namespace binrev{
namespace brCore{
template <typename T>
class DLL_EXPORT brSingleton
{
public:
static T& getInstance()
{
std::call_once(m_once, safe_create);
return *m_instance;
}
protected:
brSingleton(const std::string& name)
: m_name(name)
{}
static void safe_create() {
brSingleton::m_instance.reset(new T());
}
brSingleton(const brSingleton& rs) = delete;
brSingleton& operator = (const brSingleton& rs) = delete;
virtual ~brSingleton(){}
protected:
static std::unique_ptr<T> m_instance;
static std::once_flag m_once;
std::string m_name;
};
template<typename T>
std::once_flag brSingleton<T>::m_once;
}// ns-brCore
}// ns-binrev
如果我在具体的singleton实现中调用getInstance,那么在std::call_once函数调用时就会发生崩溃。
我没什么主意了。有人知道出了什么问题吗?谢谢
第四次安装xubuntu 13.10 64bit后,问题得到了解决。我认为syam在安装过程中提到了一些包装损坏。