For a (private) project I'm working on I build using Clang with the libc++ standard library.
To be able to link I need to use Clang and libc++ when building librethinkdb++ too. Building is not a problem, the problem comes when I try to run the code when I get a crash.
Here is the simple example program I use to test this:
#include <iostream>
#include <rethinkdb.h>
namespace R = RethinkDB;
int main()
{
auto conn = R::connect();
if (conn)
{
std::cout << "Connected\n" << std::flush;
R::Cursor databases = R::db_list().run(*conn);
for (R::Datum const& db : databases)
{
std::cout << *db.get_string() << '\n';
}
}
else
{
std::cerr << "Could not connect to server\n";
}
return 0;
}
I build using the above program using the same flags as the library is, and link with the static library (static or shared doesn't matter):
clang++ -stdlib=libc++ -ggdb -std=c++11 -I'build/gen' -Wall -pthread -fPIC list_databases.cpp -o list_databases build/librethinkdb++.a
When I run the program this happens:
Connected
*** Error in `./list_databases': double free or corruption (!prev): 0x000000000172a240 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70c8b)[0x7f9ef366dc8b]
/lib/x86_64-linux-gnu/libc.so.6(+0x77066)[0x7f9ef3674066]
/lib/x86_64-linux-gnu/libc.so.6(+0x7785e)[0x7f9ef367485e]
./list_databases[0x404f62]
./list_databases[0x404ba5]
./list_databases[0x457239]
./list_databases[0x455574]
./list_databases[0x404344]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f9ef361d2b1]
./list_databases[0x4036da]
======= Memory map: ========
00400000-0046c000 r-xp 00000000 08:04 15074177 /home/arrow/tmp/librethinkdbxx/list_databases
0066b000-0066c000 r--p 0006b000 08:04 15074177 /home/arrow/tmp/librethinkdbxx/list_databases
0066c000-0066d000 rw-p 0006c000 08:04 15074177 /home/arrow/tmp/librethinkdbxx/list_databases
01728000-01749000 rw-p 00000000 00:00 0 [heap]
7f9eec000000-7f9eec021000 rw-p 00000000 00:00 0
7f9eec021000-7f9ef0000000 ---p 00000000 00:00 0
7f9ef2f9c000-7f9ef2fa6000 r-xp 00000000 08:01 1570680 /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f9ef2fa6000-7f9ef31a6000 ---p 0000a000 08:01 1570680 /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f9ef31a6000-7f9ef31a7000 r--p 0000a000 08:01 1570680 /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f9ef31a7000-7f9ef31a8000 rw-p 0000b000 08:01 1570680 /lib/x86_64-linux-gnu/libnss_files-2.24.so
7f9ef31a8000-7f9ef31ae000 rw-p 00000000 00:00 0
7f9ef31ae000-7f9ef31b5000 r-xp 00000000 08:01 1570696 /lib/x86_64-linux-gnu/librt-2.24.so
7f9ef31b5000-7f9ef33b4000 ---p 00007000 08:01 1570696 /lib/x86_64-linux-gnu/librt-2.24.so
7f9ef33b4000-7f9ef33b5000 r--p 00006000 08:01 1570696 /lib/x86_64-linux-gnu/librt-2.24.so
7f9ef33b5000-7f9ef33b6000 rw-p 00007000 08:01 1570696 /lib/x86_64-linux-gnu/librt-2.24.so
7f9ef33b6000-7f9ef33fb000 r-xp 00000000 08:01 150256 /usr/local/lib/libc++abi.so.1.0
7f9ef33fb000-7f9ef35fa000 ---p 00045000 08:01 150256 /usr/local/lib/libc++abi.so.1.0
7f9ef35fa000-7f9ef35fc000 r--p 00044000 08:01 150256 /usr/local/lib/libc++abi.so.1.0
7f9ef35fc000-7f9ef35fd000 rw-p 00046000 08:01 150256 /usr/local/lib/libc++abi.so.1.0
7f9ef35fd000-7f9ef3792000 r-xp 00000000 08:01 1570372 /lib/x86_64-linux-gnu/libc-2.24.so
7f9ef3792000-7f9ef3992000 ---p 00195000 08:01 1570372 /lib/x86_64-linux-gnu/libc-2.24.so
7f9ef3992000-7f9ef3996000 r--p 00195000 08:01 1570372 /lib/x86_64-linux-gnu/libc-2.24.so
7f9ef3996000-7f9ef3998000 rw-p 00199000 08:01 1570372 /lib/x86_64-linux-gnu/libc-2.24.so
7f9ef3998000-7f9ef399c000 rw-p 00000000 00:00 0
7f9ef399c000-7f9ef39b4000 r-xp 00000000 08:01 1570692 /lib/x86_64-linux-gnu/libpthread-2.24.so
7f9ef39b4000-7f9ef3bb3000 ---p 00018000 08:01 1570692 /lib/x86_64-linux-gnu/libpthread-2.24.so
7f9ef3bb3000-7f9ef3bb4000 r--p 00017000 08:01 1570692 /lib/x86_64-linux-gnu/libpthread-2.24.so
7f9ef3bb4000-7f9ef3bb5000 rw-p 00018000 08:01 1570692 /lib/x86_64-linux-gnu/libpthread-2.24.so
7f9ef3bb5000-7f9ef3bb9000 rw-p 00000000 00:00 0
7f9ef3bb9000-7f9ef3bcf000 r-xp 00000000 08:01 1569953 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f9ef3bcf000-7f9ef3dce000 ---p 00016000 08:01 1569953 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f9ef3dce000-7f9ef3dcf000 r--p 00015000 08:01 1569953 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f9ef3dcf000-7f9ef3dd0000 rw-p 00016000 08:01 1569953 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f9ef3dd0000-7f9ef3ed3000 r-xp 00000000 08:01 1570646 /lib/x86_64-linux-gnu/libm-2.24.so
7f9ef3ed3000-7f9ef40d2000 ---p 00103000 08:01 1570646 /lib/x86_64-linux-gnu/libm-2.24.so
7f9ef40d2000-7f9ef40d3000 r--p 00102000 08:01 1570646 /lib/x86_64-linux-gnu/libm-2.24.so
7f9ef40d3000-7f9ef40d4000 rw-p 00103000 08:01 1570646 /lib/x86_64-linux-gnu/libm-2.24.so
7f9ef40d4000-7f9ef418c000 r-xp 00000000 08:01 150463 /usr/local/lib/libc++.so.1.0
7f9ef418c000-7f9ef438c000 ---p 000b8000 08:01 150463 /usr/local/lib/libc++.so.1.0
7f9ef438c000-7f9ef4391000 r--p 000b8000 08:01 150463 /usr/local/lib/libc++.so.1.0
7f9ef4391000-7f9ef4392000 rw-p 000bd000 08:01 150463 /usr/local/lib/libc++.so.1.0
7f9ef4392000-7f9ef4395000 rw-p 00000000 00:00 0
7f9ef4395000-7f9ef43b8000 r-xp 00000000 08:01 1569970 /lib/x86_64-linux-gnu/ld-2.24.so
7f9ef4587000-7f9ef458b000 rw-p 00000000 00:00 0
7f9ef45b3000-7f9ef45b7000 rw-p 00000000 00:00 0
7f9ef45b7000-7f9ef45b8000 r--p 00022000 08:01 1569970 /lib/x86_64-linux-gnu/ld-2.24.so
7f9ef45b8000-7f9ef45b9000 rw-p 00023000 08:01 1569970 /lib/x86_64-linux-gnu/ld-2.24.so
7f9ef45b9000-7f9ef45ba000 rw-p 00000000 00:00 0
7fffe860c000-7fffe862d000 rw-p 00000000 00:00 0 [stack]
7fffe8726000-7fffe8729000 r--p 00000000 00:00 0 [vvar]
7fffe8729000-7fffe872b000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
fish: Job 2, “./list_databases” terminated by signal SIGABRT (Abort)
Valgrind gives more details:
==29615== Memcheck, a memory error detector
==29615== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==29615== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==29615== Command: ./list_databases
==29615==
Connected
==29615== Invalid read of size 8
==29615== at 0x457384: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1329)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Address 0x6038bb8 is 8 bytes inside a block of size 32 free'd
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x457673: __deallocate (new:176)
==29615== by 0x457673: deallocate (memory:1762)
==29615== by 0x457673: deallocate (memory:1522)
==29615== by 0x457673: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::deallocate() (vector:935)
==29615== by 0x4572FE: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1327)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Block was alloc'd at
==29615== at 0x4C2ABCF: malloc (vg_replace_malloc.c:299)
==29615== by 0x4EBCA59: operator new(unsigned long) (in /usr/local/lib/libc++.so.1.0)
==29615== by 0x40F170: __allocate (new:168)
==29615== by 0x40F170: allocate (memory:1759)
==29615== by 0x40F170: allocate (memory:1514)
==29615== by 0x40F170: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::allocate(unsigned long) (vector:923)
==29615== by 0x40EF7F: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1197)
==29615== by 0x40DC32: RethinkDB::Response::Response(RethinkDB::Datum&&) (connection_p.h:53)
==29615== by 0x408A01: RethinkDB::ReadLock::read_loop(unsigned long, RethinkDB::CacheLock&&, double) (connection.cc:263)
==29615== by 0x4085BF: RethinkDB::ConnectionPrivate::wait_for_response(unsigned long, double) (connection.cc:221)
==29615== by 0x40A2BE: RethinkDB::Connection::start_query(RethinkDB::Term*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (connection.cc:328)
==29615== by 0x4415AC: RethinkDB::Term::run(RethinkDB::Connection&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (term.cc:58)
==29615== by 0x40415E: main (list_databases.cpp:12)
==29615==
==29615== Invalid read of size 8
==29615== at 0x457398: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1330)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Address 0x6038bc0 is 16 bytes inside a block of size 32 free'd
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x457673: __deallocate (new:176)
==29615== by 0x457673: deallocate (memory:1762)
==29615== by 0x457673: deallocate (memory:1522)
==29615== by 0x457673: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::deallocate() (vector:935)
==29615== by 0x4572FE: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1327)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Block was alloc'd at
==29615== at 0x4C2ABCF: malloc (vg_replace_malloc.c:299)
==29615== by 0x4EBCA59: operator new(unsigned long) (in /usr/local/lib/libc++.so.1.0)
==29615== by 0x40F170: __allocate (new:168)
==29615== by 0x40F170: allocate (memory:1759)
==29615== by 0x40F170: allocate (memory:1514)
==29615== by 0x40F170: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::allocate(unsigned long) (vector:923)
==29615== by 0x40EF7F: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1197)
==29615== by 0x40DC32: RethinkDB::Response::Response(RethinkDB::Datum&&) (connection_p.h:53)
==29615== by 0x408A01: RethinkDB::ReadLock::read_loop(unsigned long, RethinkDB::CacheLock&&, double) (connection.cc:263)
==29615== by 0x4085BF: RethinkDB::ConnectionPrivate::wait_for_response(unsigned long, double) (connection.cc:221)
==29615== by 0x40A2BE: RethinkDB::Connection::start_query(RethinkDB::Term*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (connection.cc:328)
==29615== by 0x4415AC: RethinkDB::Term::run(RethinkDB::Connection&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (term.cc:58)
==29615== by 0x40415E: main (list_databases.cpp:12)
==29615==
==29615== Invalid read of size 8
==29615== at 0x4573C3: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1331)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Address 0x6038bc8 is 24 bytes inside a block of size 32 free'd
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x457673: __deallocate (new:176)
==29615== by 0x457673: deallocate (memory:1762)
==29615== by 0x457673: deallocate (memory:1522)
==29615== by 0x457673: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::deallocate() (vector:935)
==29615== by 0x4572FE: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1327)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Block was alloc'd at
==29615== at 0x4C2ABCF: malloc (vg_replace_malloc.c:299)
==29615== by 0x4EBCA59: operator new(unsigned long) (in /usr/local/lib/libc++.so.1.0)
==29615== by 0x40F170: __allocate (new:168)
==29615== by 0x40F170: allocate (memory:1759)
==29615== by 0x40F170: allocate (memory:1514)
==29615== by 0x40F170: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::allocate(unsigned long) (vector:923)
==29615== by 0x40EF7F: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1197)
==29615== by 0x40DC32: RethinkDB::Response::Response(RethinkDB::Datum&&) (connection_p.h:53)
==29615== by 0x408A01: RethinkDB::ReadLock::read_loop(unsigned long, RethinkDB::CacheLock&&, double) (connection.cc:263)
==29615== by 0x4085BF: RethinkDB::ConnectionPrivate::wait_for_response(unsigned long, double) (connection.cc:221)
==29615== by 0x40A2BE: RethinkDB::Connection::start_query(RethinkDB::Term*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (connection.cc:328)
==29615== by 0x4415AC: RethinkDB::Term::run(RethinkDB::Connection&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (term.cc:58)
==29615== by 0x40415E: main (list_databases.cpp:12)
==29615==
==29615== Invalid write of size 8
==29615== at 0x457408: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1332)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Address 0x6038bc8 is 24 bytes inside a block of size 32 free'd
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x457673: __deallocate (new:176)
==29615== by 0x457673: deallocate (memory:1762)
==29615== by 0x457673: deallocate (memory:1522)
==29615== by 0x457673: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::deallocate() (vector:935)
==29615== by 0x4572FE: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1327)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Block was alloc'd at
==29615== at 0x4C2ABCF: malloc (vg_replace_malloc.c:299)
==29615== by 0x4EBCA59: operator new(unsigned long) (in /usr/local/lib/libc++.so.1.0)
==29615== by 0x40F170: __allocate (new:168)
==29615== by 0x40F170: allocate (memory:1759)
==29615== by 0x40F170: allocate (memory:1514)
==29615== by 0x40F170: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::allocate(unsigned long) (vector:923)
==29615== by 0x40EF7F: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1197)
==29615== by 0x40DC32: RethinkDB::Response::Response(RethinkDB::Datum&&) (connection_p.h:53)
==29615== by 0x408A01: RethinkDB::ReadLock::read_loop(unsigned long, RethinkDB::CacheLock&&, double) (connection.cc:263)
==29615== by 0x4085BF: RethinkDB::ConnectionPrivate::wait_for_response(unsigned long, double) (connection.cc:221)
==29615== by 0x40A2BE: RethinkDB::Connection::start_query(RethinkDB::Term*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (connection.cc:328)
==29615== by 0x4415AC: RethinkDB::Term::run(RethinkDB::Connection&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (term.cc:58)
==29615== by 0x40415E: main (list_databases.cpp:12)
==29615==
==29615== Invalid write of size 8
==29615== at 0x457416: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1332)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Address 0x6038bc0 is 16 bytes inside a block of size 32 free'd
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x457673: __deallocate (new:176)
==29615== by 0x457673: deallocate (memory:1762)
==29615== by 0x457673: deallocate (memory:1522)
==29615== by 0x457673: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::deallocate() (vector:935)
==29615== by 0x4572FE: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1327)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Block was alloc'd at
==29615== at 0x4C2ABCF: malloc (vg_replace_malloc.c:299)
==29615== by 0x4EBCA59: operator new(unsigned long) (in /usr/local/lib/libc++.so.1.0)
==29615== by 0x40F170: __allocate (new:168)
==29615== by 0x40F170: allocate (memory:1759)
==29615== by 0x40F170: allocate (memory:1514)
==29615== by 0x40F170: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::allocate(unsigned long) (vector:923)
==29615== by 0x40EF7F: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1197)
==29615== by 0x40DC32: RethinkDB::Response::Response(RethinkDB::Datum&&) (connection_p.h:53)
==29615== by 0x408A01: RethinkDB::ReadLock::read_loop(unsigned long, RethinkDB::CacheLock&&, double) (connection.cc:263)
==29615== by 0x4085BF: RethinkDB::ConnectionPrivate::wait_for_response(unsigned long, double) (connection.cc:221)
==29615== by 0x40A2BE: RethinkDB::Connection::start_query(RethinkDB::Term*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (connection.cc:328)
==29615== by 0x4415AC: RethinkDB::Term::run(RethinkDB::Connection&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (term.cc:58)
==29615== by 0x40415E: main (list_databases.cpp:12)
==29615==
==29615== Invalid write of size 8
==29615== at 0x457425: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1332)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Address 0x6038bb8 is 8 bytes inside a block of size 32 free'd
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x457673: __deallocate (new:176)
==29615== by 0x457673: deallocate (memory:1762)
==29615== by 0x457673: deallocate (memory:1522)
==29615== by 0x457673: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::deallocate() (vector:935)
==29615== by 0x4572FE: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1327)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Block was alloc'd at
==29615== at 0x4C2ABCF: malloc (vg_replace_malloc.c:299)
==29615== by 0x4EBCA59: operator new(unsigned long) (in /usr/local/lib/libc++.so.1.0)
==29615== by 0x40F170: __allocate (new:168)
==29615== by 0x40F170: allocate (memory:1759)
==29615== by 0x40F170: allocate (memory:1514)
==29615== by 0x40F170: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::allocate(unsigned long) (vector:923)
==29615== by 0x40EF7F: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1197)
==29615== by 0x40DC32: RethinkDB::Response::Response(RethinkDB::Datum&&) (connection_p.h:53)
==29615== by 0x408A01: RethinkDB::ReadLock::read_loop(unsigned long, RethinkDB::CacheLock&&, double) (connection.cc:263)
==29615== by 0x4085BF: RethinkDB::ConnectionPrivate::wait_for_response(unsigned long, double) (connection.cc:221)
==29615== by 0x40A2BE: RethinkDB::Connection::start_query(RethinkDB::Term*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (connection.cc:328)
==29615== by 0x4415AC: RethinkDB::Term::run(RethinkDB::Connection&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, RethinkDB::Term, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, RethinkDB::Term> > >&&) (term.cc:58)
==29615== by 0x40415E: main (list_databases.cpp:12)
==29615==
==29615== Invalid free() / delete / delete[] / realloc()
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x404F61: __deallocate (new:176)
==29615== by 0x404F61: deallocate (memory:1762)
==29615== by 0x404F61: deallocate (memory:1522)
==29615== by 0x404F61: std::__1::__vector_base<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::~__vector_base() (vector:445)
==29615== by 0x404BA4: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::~vector() (vector:450)
==29615== by 0x457238: RethinkDB::CursorPrivate::~CursorPrivate() (cursor_p.h:8)
==29615== by 0x455573: operator() (memory:2565)
==29615== by 0x455573: reset (memory:2771)
==29615== by 0x455573: ~unique_ptr (memory:2739)
==29615== by 0x455573: RethinkDB::Cursor::~Cursor() (cursor.cc:27)
==29615== by 0x404343: main (list_databases.cpp:17)
==29615== Address 0x6038c10 is 0 bytes inside a block of size 128 free'd
==29615== at 0x4C2BDFB: free (vg_replace_malloc.c:530)
==29615== by 0x404F61: __deallocate (new:176)
==29615== by 0x404F61: deallocate (memory:1762)
==29615== by 0x404F61: deallocate (memory:1522)
==29615== by 0x404F61: std::__1::__vector_base<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::~__vector_base() (vector:445)
==29615== by 0x404BA4: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::~vector() (vector:450)
==29615== by 0x404B36: RethinkDB::Datum::datum_value::destroy(RethinkDB::Datum::Type) (datum.h:268)
==29615== by 0x404A43: RethinkDB::Datum::~Datum() (datum.h:105)
==29615== by 0x457591: destroy (memory:1826)
==29615== by 0x457591: __destroy<RethinkDB::Datum> (memory:1694)
==29615== by 0x457591: destroy<RethinkDB::Datum> (memory:1562)
==29615== by 0x457591: __destruct_at_end (vector:417)
==29615== by 0x457591: clear (vector:361)
==29615== by 0x457591: clear (vector:731)
==29615== by 0x457591: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::deallocate() (vector:934)
==29615== by 0x4572FE: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::__move_assign(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >&, std::__1::integral_constant<bool, true>) (vector:1327)
==29615== by 0x455CFD: operator= (vector:1303)
==29615== by 0x455CFD: RethinkDB::CursorPrivate::convert_single() const (cursor.cc:60)
==29615== by 0x4557C6: RethinkDB::Cursor::has_next(double) const (cursor.cc:121)
==29615== by 0x456D3D: RethinkDB::Cursor::iterator::operator!=(RethinkDB::Cursor::iterator const&) const (cursor.cc:211)
==29615== by 0x4041E1: main (list_databases.cpp:13)
==29615== Block was alloc'd at
==29615== at 0x4C2ABCF: malloc (vg_replace_malloc.c:299)
==29615== by 0x4EBCA59: operator new(unsigned long) (in /usr/local/lib/libc++.so.1.0)
==29615== by 0x40F170: __allocate (new:168)
==29615== by 0x40F170: allocate (memory:1759)
==29615== by 0x40F170: allocate (memory:1514)
==29615== by 0x40F170: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::allocate(unsigned long) (vector:923)
==29615== by 0x40EF7F: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1197)
==29615== by 0x41160F: RethinkDB::Datum::datum_value::set(RethinkDB::Datum::Type, RethinkDB::Datum::datum_value const&) (datum.h:254)
==29615== by 0x410F82: RethinkDB::Datum::datum_value::datum_value(RethinkDB::Datum::Type, RethinkDB::Datum::datum_value const&) (datum.h:227)
==29615== by 0x40E74F: RethinkDB::Datum::Datum(RethinkDB::Datum const&) (datum.h:43)
==29615== by 0x40F320: construct<RethinkDB::Datum, RethinkDB::Datum &> (memory:1771)
==29615== by 0x40F320: __construct<RethinkDB::Datum, RethinkDB::Datum &> (memory:1682)
==29615== by 0x40F320: construct<RethinkDB::Datum, RethinkDB::Datum &> (memory:1528)
==29615== by 0x40F320: __construct_range_forward<RethinkDB::Datum *, RethinkDB::Datum *> (memory:1612)
==29615== by 0x40F320: _ZNSt3__16vectorIN9RethinkDB5DatumENS_9allocatorIS2_EEE18__construct_at_endIPS2_EENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeES9_S9_m (vector:1015)
==29615== by 0x40EFA5: std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> >::vector(std::__1::vector<RethinkDB::Datum, std::__1::allocator<RethinkDB::Datum> > const&) (vector:1198)
==29615== by 0x40DC32: RethinkDB::Response::Response(RethinkDB::Datum&&) (connection_p.h:53)
==29615== by 0x408A01: RethinkDB::ReadLock::read_loop(unsigned long, RethinkDB::CacheLock&&, double) (connection.cc:263)
==29615== by 0x4085BF: RethinkDB::ConnectionPrivate::wait_for_response(unsigned long, double) (connection.cc:221)
==29615==
==29615==
==29615== HEAP SUMMARY:
==29615== in use at exit: 0 bytes in 0 blocks
==29615== total heap usage: 105 allocs, 106 frees, 102,478 bytes allocated
==29615==
==29615== All heap blocks were freed -- no leaks are possible
==29615==
==29615== For counts of detected and suppressed errors, rerun with: -v
==29615== ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)
Is it a mistake on my part? A but in Clang? A bug in libc++? Or a bug in librethinkdb++?
I am using a recent (a few days old) checkout of Clang and libc++ and built from source.
I'm on a Debian SID system, recently updated (also a couple of days ago).
I do not have this problem if I use -stdlib=libstdc++
(the GNU GCC standard library) for both the library and my application, even when building with Clang. It's only in combination with libc++ this crash happens.