-1

最近我将我的操作系统更新到了 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)

我已经从源代码中删除了任何东西,并且只使用了一个空的 main 函数:

#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.

编辑:

同时我发现问题出在我的单例实现上。此实现在与 GCC 4.8 和 Xubuntu 13.04 握手时成功地与 MinGW-64 一起工作:

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

如果我在具体的单例实现中调用 getInstance ,则会在 std::call_once 函数调用上发生崩溃。

我的想法不多了。有谁知道出了什么问题?谢谢。

4

1 回答 1

0

第四次安装 xubuntu 13.10 64bit 后问题得到解决。我认为 syam 在安装过程中提到了一些包装损坏。

于 2013-12-01T09:15:39.113 回答