c – gcc5.2 abi更改 – >兼容性保证?

c – gcc5.2 abi更改 – >兼容性保证?,第1张

概述我有以下情况(Ubuntu 15.10和Debian测试) 我有一个没有cxx11编译的Lib A和一个使用-std = c 11的lib B. B包含和A的链接,A使用boost. 如果我将B链接到A,则在dynload期间A创建的应用程序崩溃. 如果我编译A没有cxx11或B与cxx11一切正常. 我的问题:到目前为止我理解ABI名称空间添加应该保证这样的问题.我错了吗? 我创建了一个示例项目 我有以下情况(Ubuntu 15.10和Debian测试)

我有一个没有cxx11编译的lib A和一个使用-std = c 11的lib B. B包含和A的链接,A使用boost.

如果我将B链接到A,则在dynload期间A创建的应用程序崩溃.
如果我编译A没有cxx11或B与cxx11一切正常.

我的问题:到目前为止我理解ABI名称空间添加应该保证这样的问题.我错了吗?

我创建了一个示例项目来澄清问题:
https://github.com/goldhoorn/sandbox/tree/gcc5.2-issue
test1失败,其他测试通过.

GDB告诉我:

Program received signal SIGSEGV,Segmentation fault.0x00007ffff7bceb2e in _GLOBAL__sub_I_lib.cpp () from ./libmylib.so(gdb) bt#0  0x00007ffff7bceb2e in _GLOBAL__sub_I_lib.cpp () from ./libmylib.so#1  0x00007ffff7deaa0a in call_init (l=<optimized out>,argc=argc@entry=1,argv=argv@entry=0x7fffffffe688,env=env@entry=0x7fffffffe698)at dl-init.c:78#2  0x00007ffff7deaaf3 in call_init (env=0x7fffffffe698,argv=0x7fffffffe688,argc=1,l=<optimized out>) at dl-init.c:36#3  _dl_init (main_map=0x7ffff7ffe1a8,env=0x7fffffffe698) at dl-init.c:126#4  0x00007ffff7ddd1ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2#5  0x0000000000000001 in ?? ()#6  0x00007fffffffe89f in ?? ()#7  0x0000000000000000 in ?? ()

Valgrind的结果:

goldhoorn@debian:/tmp/example$LD_liBRARY_PATH=. valgrind --show-below-main=yes ./main ==17140== Memcheck,a memory error detector==17140== copyright (C) 2002-2015,and GNU GPL'd,by Julian Seward et al.==17140== Using Valgrind-3.11.0 and libVEX; rerun with -h for copyright info==17140== Command: ./main==17140== ==17140== ==17140== Process terminating with default action of signal 11 (SIGSEGV)==17140==  Bad permissions for mapped region at address 0x401FE8==17140==    at 0x4E3EB2E: _GLOBAL__sub_I_lib.cpp (in /tmp/example/libmylib.so)==17140==    by 0x400EA09: call_init.part.0 (dl-init.c:78)==17140==    by 0x400EAF2: call_init (dl-init.c:36)==17140==    by 0x400EAF2: _dl_init (dl-init.c:126)==17140==    by 0x40011C9: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)==17140== ==17140== HEAP SUMMARY:==17140==     in use at exit: 72,704 bytes in 1 blocks==17140==   total heap usage: 1 allocs,0 frees,72,704 bytes allocated==17140== ==17140== LEAK SUMMARY:==17140==    definitely lost: 0 bytes in 0 blocks==17140==    indirectly lost: 0 bytes in 0 blocks==17140==      possibly lost: 0 bytes in 0 blocks==17140==    still reachable: 72,704 bytes in 1 blocks==17140==         suppressed: 0 bytes in 0 blocks==17140== Rerun with --leak-check=full to see details of leaked memory==17140== ==17140== For counts of detected and suppressed errors,rerun with: -v==17140== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)Segmentation fault
解决方法 请根据Cxx11 ABI向后不兼容性列表检查您的库A: https://gcc.gnu.org/wiki/Cxx11AbiCompatibility

The C++98 language is ABI-compatible with the C++11 language,but several places in the library break compatibility. This makes it dangerous to link C++98 objects with C++11 objects.

总结

以上是内存溢出为你收集整理的c – gcc5.2 abi更改 – >兼容性保证?全部内容,希望文章能够帮你解决c – gcc5.2 abi更改 – >兼容性保证?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1224624.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-05
下一篇2022-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存