为什么在使用gcc 4.7编译时会出现此堆栈跟踪,而在使用旧版本的4.3之前版本时不会出现
Why is this stack trace appearing when compiled with gcc 4.7 but not with older pre 4.3?
我有一个相当大的二进制文件,我已经在相当旧的GCC(4.1.2)版本上构建了一段时间。我最近用4.7构建了它,但当我运行它时,它会崩溃,并出现以下回溯:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
Program received signal SIGABRT, Aborted.
0x000003728472c5 in raise() from /lib64/libc.so.6
(gdb) bt
#0 0xbla in raise () from /lib64/libc.so.6
#1 0xbla in abort() from /lib64/libc.so.6
#2 0xbla in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib64/libstdc++.so.6
#3 0xbla in ?? () from /usr/lib64/libstdc++.so.6
#4 0xbla in std::terminate() () from /usr/lib64/libstdc++.so.6
#5 0xbla in __cxa_throw () from /usr/lib64/libstdc++.so.6
#6 0xbla in std::__throw_logic_error(char const*) () from /usr/lib64/libstdc++.so.6
#7 0x00000024727472 in ?? () from /usr/lib64/libstdc++.so.6
#8 0xbla in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib64/libdstdc++.so.6
#9 0xbla in CFGS_XML_Parser::ns_name (name=0x12283c0 "name") at CFGS_XML_Parser.H:258
#10 0xbla in __static_initialization_and_destruction_0 (__initialize_p=1,__priority=65535)
#11 0xbla in _GLOBAL__sub_I__Z15init_xml_loaderv () at CFGS_XML_Loader.C:728
#12 0xbla in __libc_csu_init()
#13 0xbla in __libc_start_main () from /lib64/libc.so.6
#14 0xbla in _start ()
我不知道这是在抱怨什么,也不知道为什么它只会是gcc 4.7。它可能是什么?我如何调试它?
正如Mats-Petersson正确指出的,您正试图从const char *
构建std::string
,即NULL
。
旧的GCC没有发生这种情况,而新的GCC发生这种情况的可能原因是GCC-4.7停止使用.ctors
并开始使用.init_array
。看见http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
正如Mats-Petersson可能正确猜测的那样,您已经依赖于独立编译单元之间的初始值设定项顺序,现在这个顺序发生了变化(顺序未定义),您正在为此付出代价。
我们在100+MLOC的代码库中遇到了这个确切的问题,我们的解决方案是用configure --disable-initfini-array ...
重新配置GCC(我们构建自己的GCC版本)。
请注意,某些平台(例如ARM
)不支持.ctors
,仅支持.init_array
s。
相关文章:
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 导入库可以跨dll版本工作吗
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- 光线跟踪器灯光反射错误
- 在clang++预处理器中确定gcc工具链版本
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 人脸跟踪arduino代码的优化
- 不同的Visual Studio版本中缺少.dll
- 用符号版本替换对函数的所有调用
- luaL_dofile在已知良好的字节码上失败,可以使用未编译的版本
- 跟踪滚动条上的鼠标事件
- 正在解码MSVC 32位版本的程序集(作业).没有手术做什么
- 我需要分发哪些版本的可再分发文件
- 如何使用新运算符跟踪在循环中创建的 QLabel
- CV_OCL_RUN宏如何在OpenCV(版本3.4.5)的goodFeaturesToTrack实现中工作?
- 在运行时读取 libstdc++ 版本
- 如何声明一个可以在整个程序中使用的全局 2d 3d 4d .. 数组(堆版本)变量?
- 调试:跟踪(和diffing)同一程序的两个版本的函数调用树
- 为什么在使用gcc 4.7编译时会出现此堆栈跟踪,而在使用旧版本的4.3之前版本时不会出现
- 跟踪可执行文件中的代码版本