谁能帮助我理解以下segfault 11错误?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00000000004425e0 in boost::system::error_category::equivalent(boost::system::error_code const&, int) const ()
(gdb) where
#0 0x00000000004425e0 in boost::system::error_category::equivalent(boost::system::error_code const&, int) const ()
#1 0x0000000000414a58 in _GLOBAL__sub_I_operations.cpp ()
#2 0x000000000047d40d in __libc_csu_init ()
#3 0x00002aaaab9b24d5 in __libc_start_main (main=0x414730 <main>, argc=1, argv=0x7fffffff9b38, init=0x47d3c0 <__libc_csu_init>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffff9b28) at ../csu/libc-start.c:225
#4 0x0000000000414a90 in _start ()
看起来有什么东西可能会在Boost系统的静态数据被初始化之前引发错误¹。
在这种情况下,最可能的罪魁祸首是带有非平凡构造函数的全局变量。
如果构造函数在开始之前就试图做一些事情,那么就会产生错误。main
可能会因为相关库尚未初始化而落下。
¹参见 "静态初始化顺序惨败"
在这里找到了解决方案。使用boost::filesystem时出现的分割故障
我没有用与我的应用程序相同的标志来编译boost......特别是-std=c++14。