c++ - g++ program linked against clang++ shared lib with shared_pointers -


i've been working on personal parser few month now. @ each step, have verified able compile , work either clang++ or g++. , ok since ( project doesn't use other library stl ). want slice project in 2 part : shared library , program main.cpp file. want because "real" project library, executable exemple of application and/or way test library.

note : compile library no warning :

  • for each cpp file : g++/clang++ -std=c++11 -wall -fpic -c file.cpp -o file.o
  • for lib : g++/clang++ -std=c++11 -wall -fpic -shared -wl,-soname,libname.so.0 files.o... -o libname.so.0.1

when compile program same compiler library, good. when compile other (still no warning), application crashes @ execution :

*** error in `./math': double free or corruption (fasttop): 0x0000000000f55910 *** ======= backtrace: ========= /lib64/libc.so.6(+0x7b1d6)[0x7f80d76eb1d6] ./libtssa.so.0(__gnu_cxx::new_allocator<std::shared_ptr<textnode> >::deallocate(std::shared_ptr<textnode>*, unsigned long)+0x20)[0x7f80d82baee0] ./libtssa.so.0(std::_vector_base<std::shared_ptr<textnode>, std::allocator<std::shared_ptr<textnode> > >::_m_deallocate(std::shared_ptr<textnode>*, unsigned long)+0x3e)[0x7f80d82bae3e] ./libtssa.so.0(std::_vector_base<std::shared_ptr<textnode>, std::allocator<std::shared_ptr<textnode> > >::~_vector_base()+0x2c)[0x7f80d82badcc] ./libtssa.so.0(std::vector<std::shared_ptr<textnode>, std::allocator<std::shared_ptr<textnode> > >::~vector()+0x50)[0x7f80d82bad40] ./libtssa.so.0(std::vector<std::shared_ptr<textnode>, std::allocator<std::shared_ptr<textnode> > >::~vector()+0x15)[0x7f80d82bace5] ./libtssa.so.0(node<textnode>::~node()+0x15)[0x7f80d82bacc5] ./libtssa.so.0(textnode::~textnode()+0x31)[0x7f80d82baca1] ./libtssa.so.0(textnode::~textnode()+0x15)[0x7f80d82bac65] ./libtssa.so.0(void __gnu_cxx::new_allocator<textnode>::destroy<textnode>(textnode*)+0x19)[0x7f80d82bac49] ./libtssa.so.0(_znst16allocator_traitsisai8textnodeee10_s_destroyis0_eenst9enable_ifixsr16__destroy_helperit_ee5valueeve4typeers1_ps5_+0x28)[0x7f80d82bac28] ./libtssa.so.0(void std::allocator_traits<std::allocator<textnode> >::destroy<textnode>(std::allocator<textnode>&, textnode*)+0x1d)[0x7f80d82babed] ./libtssa.so.0(std::_sp_counted_ptr_inplace<textnode, std::allocator<textnode>, (__gnu_cxx::_lock_policy)1>::_m_dispose()+0x1f)[0x7f80d82ba99f] ./math[0x4079ce] ./math[0x40744f] ./math[0x407106] ./math(std::shared_ptr<textnode>::~shared_ptr()+0x18)[0x407120] ./libtssa.so.0(void std::_destroy<std::shared_ptr<textnode> >(std::shared_ptr<textnode>*)+0x15)[0x7f80d82baf85] ./libtssa.so.0(void std::_destroy_aux<false>::__destroy<std::shared_ptr<textnode>*>(std::shared_ptr<textnode>*, std::shared_ptr<textnode>*)+0x2f)[0x7f80d82baf4f] ./libtssa.so.0(void std::_destroy<std::shared_ptr<textnode>*>(std::shared_ptr<textnode>*, std::shared_ptr<textnode>*)+0x1d)[0x7f80d82baf0d] ./libtssa.so.0(void std::_destroy<std::shared_ptr<textnode>*, std::shared_ptr<textnode> >(std::shared_ptr<textnode>*, std::shared_ptr<textnode>*, std::allocator<std::shared_ptr<textnode> >&)+0x21)[0x7f80d82bad81] ./libtssa.so.0(std::vector<std::shared_ptr<textnode>, std::allocator<std::shared_ptr<textnode> > >::~vector()+0x3f)[0x7f80d82bad2f] ./libtssa.so.0(std::vector<std::shared_ptr<textnode>, std::allocator<std::shared_ptr<textnode> > >::~vector()+0x15)[0x7f80d82bace5] ./libtssa.so.0(node<textnode>::~node()+0x15)[0x7f80d82bacc5] ./libtssa.so.0(textnode::~textnode()+0x31)[0x7f80d82baca1] ./libtssa.so.0(textnode::~textnode()+0x15)[0x7f80d82bac65] ./libtssa.so.0(void __gnu_cxx::new_allocator<textnode>::destroy<textnode>(textnode*)+0x19)[0x7f80d82bac49] ./libtssa.so.0(_znst16allocator_traitsisai8textnodeee10_s_destroyis0_eenst9enable_ifixsr16__destroy_helperit_ee5valueeve4typeers1_ps5_+0x28)[0x7f80d82bac28] ./libtssa.so.0(void std::allocator_traits<std::allocator<textnode> >::destroy<textnode>(std::allocator<textnode>&, textnode*)+0x1d)[0x7f80d82babed] ./libtssa.so.0(std::_sp_counted_ptr_inplace<textnode, std::allocator<textnode>, (__gnu_cxx::_lock_policy)1>::_m_dispose()+0x1f)[0x7f80d82ba99f] ./math[0x4079ce] ./math[0x40744f] ./math[0x407106] ./math(std::shared_ptr<textnode>::~shared_ptr()+0x18)[0x407120] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x4a5)[0x7f80d82bdd15] ./libtssa.so.0(optionnal::analyse(analysis&, unsigned long) const+0xe5)[0x7f80d82bfed5] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ./libtssa.so.0(sequence::analyse(analysis&, unsigned long) const+0x11f)[0x7f80d82c034f] ./libtssa.so.0(alternative::analyse(analysis&, unsigned long) const+0x228)[0x7f80d82bda98] ======= memory map: ======== 00400000-0040d000 r-xp 00000000 08:06 28180757                           /home/philippe/documents/developpement/analyse_syntaxique/exemples/math/build/math 0060c000-0060d000 r--p 0000c000 08:06 28180757                           /home/philippe/documents/developpement/analyse_syntaxique/exemples/math/build/math 0060d000-0060e000 rw-p 0000d000 08:06 28180757                           /home/philippe/documents/developpement/analyse_syntaxique/exemples/math/build/math 00ee8000-00f6c000 rw-p 00000000 00:00 0                                  [heap] 7f80d7670000-7f80d7819000 r-xp 00000000 08:01 130189                     /usr/lib64/libc-2.17.so 7f80d7819000-7f80d7a18000 ---p 001a9000 08:01 130189                     /usr/lib64/libc-2.17.so 7f80d7a18000-7f80d7a1c000 r--p 001a8000 08:01 130189                     /usr/lib64/libc-2.17.so 7f80d7a1c000-7f80d7a1e000 rw-p 001ac000 08:01 130189                     /usr/lib64/libc-2.17.so 7f80d7a1e000-7f80d7a22000 rw-p 00000000 00:00 0  7f80d7a22000-7f80d7a37000 r-xp 00000000 08:01 131583                     /usr/lib64/libgcc_s-4.7.2.so.1 7f80d7a37000-7f80d7c36000 ---p 00015000 08:01 131583                     /usr/lib64/libgcc_s-4.7.2.so.1 7f80d7c36000-7f80d7c37000 r--p 00014000 08:01 131583                     /usr/lib64/libgcc_s-4.7.2.so.1 7f80d7c37000-7f80d7c38000 rw-p 00015000 08:01 131583                     /usr/lib64/libgcc_s-4.7.2.so.1 7f80d7c38000-7f80d7d35000 r-xp 00000000 08:01 130197                     /usr/lib64/libm-2.17.so 7f80d7d35000-7f80d7f34000 ---p 000fd000 08:01 130197                     /usr/lib64/libm-2.17.so 7f80d7f34000-7f80d7f35000 r--p 000fc000 08:01 130197                     /usr/lib64/libm-2.17.so 7f80d7f35000-7f80d7f36000 rw-p 000fd000 08:01 130197                     /usr/lib64/libm-2.17.so 7f80d7f36000-7f80d801a000 r-xp 00000000 08:01 131588                     /usr/lib64/libstdc++.so.6.0.17 7f80d801a000-7f80d821a000 ---p 000e4000 08:01 131588                     /usr/lib64/libstdc++.so.6.0.17 7f80d821a000-7f80d8222000 r--p 000e4000 08:01 131588                     /usr/lib64/libstdc++.so.6.0.17 7f80d8222000-7f80d8224000 rw-p 000ec000 08:01 131588                     /usr/lib64/libstdc++.so.6.0.17 7f80d8224000-7f80d8239000 rw-p 00000000 00:00 0  7f80d8239000-7f80d8310000 r-xp 00000000 08:06 28180741                   /home/philippe/documents/developpement/analyse_syntaxique/build/libtssa.so.0.1 7f80d8310000-7f80d8510000 ---p 000d7000 08:06 28180741                   /home/philippe/documents/developpement/analyse_syntaxique/build/libtssa.so.0.1 7f80d8510000-7f80d8511000 r--p 000d7000 08:06 28180741                   /home/philippe/documents/developpement/analyse_syntaxique/build/libtssa.so.0.1 7f80d8511000-7f80d8517000 rw-p 000d8000 08:06 28180741                   /home/philippe/documents/developpement/analyse_syntaxique/build/libtssa.so.0.1 7f80d8517000-7f80d8536000 r-xp 00000000 08:01 130182                     /usr/lib64/ld-2.17.so 7f80d8714000-7f80d871a000 rw-p 00000000 00:00 0  7f80d8732000-7f80d8735000 rw-p 00000000 00:00 0  7f80d8735000-7f80d8736000 r--p 0001e000 08:01 130182                     /usr/lib64/ld-2.17.so 7f80d8736000-7f80d8738000 rw-p 0001f000 08:01 130182                     /usr/lib64/ld-2.17.so 7fff03120000-7fff03142000 rw-p 00000000 00:00 0                          [stack] 7fff031fe000-7fff03200000 r-xp 00000000 00:00 0                          [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall] 

in whole project don't dynamic allocation other through template function make_shared(...), think number of probable causes quite limited.

questions :

  • is there obvious should check.
  • have got advices me find bug myself, because not used read backtrace, or debuging through stl, or whatever other technics writing cout @ each lines , time start learn (i work gnu/linux , prefer not have use non-free tool).


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -