vendredi 26 mars 2021

Shared library problems between C++11 and C++14

I have had to switch from C++11 to C++14 in my project to use the Catch testing framework, written for C++14 (it doesn't compile with anything less). Everything compiles fine. However, while running the program, the following function causes a series of errors which seem linked to a mismatch between C++11 and C++14 shared standard library files:

//it is called as such:
string p = "...";
handle_file(p);

//...
int handle_file (string p) {
        if (is_valid(p)) {
            return 0;
        }
        else return -1;
    }

The error trace in gdb reads:

Program received signal SIGABRT, Aborted.
0x00007ffff7299ef5 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7299ef5 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7283862 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff72dbf38 in __libc_message () from /usr/lib/libc.so.6
#3  0x00007ffff72e3bea in malloc_printerr () from /usr/lib/libc.so.6
#4  0x00007ffff72e5113 in _int_free () from /usr/lib/libc.so.6
#5  0x00007ffff72e8ca8 in free () from /usr/lib/libc.so.6
#6  0x00007ffff76b76ea in operator delete (ptr=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/del_op.cc:49
#7  0x00007ffff76b76fa in operator delete (ptr=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/del_ops.cc:33
#8  0x000055555556c893 in __gnu_cxx::new_allocator<char>::deallocate (__t=<optimized out>, __p=<optimized out>, this=0x7fffffffd910)
    at /usr/include/c++/10.2.0/ext/new_allocator.h:133
#9  std::allocator_traits<std::allocator<char> >::deallocate (__n=<optimized out>, __p=<optimized out>, __a=...)
    at /usr/include/c++/10.2.0/bits/alloc_traits.h:492
#10 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy (__size=<optimized out>, this=0x7fffffffd910)
    at /usr/include/c++/10.2.0/bits/basic_string.h:237
#11 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose (this=0x7fffffffd910)
    at /usr/include/c++/10.2.0/bits/basic_string.h:232
#12 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string (this=0x7fffffffd910, __in_chrg=<optimized out>)
    at /usr/include/c++/10.2.0/bits/basic_string.h:658
#13 Manager::handle_file (p ="./data/20pix", this=0x5555556c6d20)
    at src/manager.hpp:149

Does anyone know how to solve this?

Aucun commentaire:

Enregistrer un commentaire