2015-11-02 2 views
4

J'ai la situation suivante (Ubuntu 15.10 et Debian Testing)gcc5.2 abi changement -> compatibilité garantie?

J'ai LibA qui est compilée sans cxx11 et une lib B qui utilise -std = C++ 11. B inclut et lie contre A, A utilise boost.

Si je liez B à A, l'application a A s'est bloquée pendant le chargement de Dynload. Si je compile A sans cxx11 ou B avec cxx11 tout fonctionne bien.

Ma question: pour autant que je sache, l'ajout de l'espace de noms ABI devrait garantir un genre de problème. Est-ce que je me trompe ici?

J'ai créé un exemple de projet pour clarifier le problème: https://github.com/goldhoorn/sandbox/tree/gcc5.2-issue test1 a échoué, les autres tests réussissant.

GDB me dit:

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>, [email protected]=1, 
[email protected]=0x7fffffffe688, [email protected]=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, argc=1, argv=0x7fffffffe688, 
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 ??() 

Résultat Valgrind:

[email protected]:/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 
+0

Avez-vous compilé avec 'g ++ -Wall -Wextra -g'? Avez-vous utilisé [valgrind] (http://valgrind.org/), 'gdb', et [address sanitizer] (http://en.wikipedia.org/wiki/AddressSanitizer) pour comprendre votre bug? plase montre un exemple de code ([MVCE] (http://stackoverflow.com/help/mcve) ...) dans votre question ... alors s'il vous plaît ** éditez votre question ** pour l'améliorer –

+1

En fait au moins 'std :: string' sur un niveau ABI différent entre '-std = C++ 11' et' -std = c = + 03', donc un mélange de standards différents crée des crashs aléatoires. Plus C++ 11 n'est pas implémenté instantanément, donc avec certaines anciennes exigences gcc 'std :: string' pas mach' C++ 11', donc vous ne pouvez pas voir de crash. – fghj

+0

@ user1034749 Pour autant que je sache, le nouvel ABI devrait aboutir au code unlinkebale. Thats mon qeustion pourquoi cela ne se produit pas ici: http://developerblog.redhat.com/2015/02/05/gcc5-and-the-c11-abi/ –

Répondre

0

S'il vous plaît vérifier votre bibliothèque A contre la liste des incompatibilités arrière Cxx11 ABI: https://gcc.gnu.org/wiki/Cxx11AbiCompatibility

Le C + Le langage +98 est compatible ABI avec le langage C++ 11, mais plusieurs endroits dans la bibliothèque cassent la compatibilité. Cela rend dangereux de lier des objets C++ 98 avec des objets C++ 11.