CompilerInstance::setInvocation fails at runtime with: "pointer being freed was not allocate" - c++

I'm trying to use Clang and I'm having issues with its reference-counting mechanism.
Whenever I try to assign a CompilerInvocation to a CompilerInstance, at runtime I get an error:
clangjit(13823,0x7fff7646f310) malloc: *** error for object 0x103002c00: pointer being freed was not allocated
This is a minimal program that reproduces the issue:
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/CompilerInvocation.h>
using namespace clang;
int main(int argc, const char* const *argv) {
CompilerInstance* CI = new CompilerInstance();
CI->setInvocation(new CompilerInvocation());
}
CompilerInstance internally does reference counting using:
IntrusiveRefCntPtr<CompilerInvocation> Invocation;
and the setter is defined as:
void CompilerInstance::setInvocation(CompilerInvocation *Value) {
Invocation = Value;
}
(I have no control over either of these since they come from Clang).
This is the stack trace at the point of failure:
#0 0x00007fff8d097866 in __pthread_kill ()
#1 0x00007fff8df2635c in pthread_kill ()
#2 0x00007fff8d03ab1a in abort ()
#3 0x00007fff8485807f in free ()
#4 0x0000000100002678 in std::__1::allocator<std::__1::__tree_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*> >::deallocate(std::__1::__tree_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*>*, unsigned long) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:1632
#5 0x000000010000266c in std::__1::allocator_traits<std::__1::allocator<std::__1::__tree_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*> > >::deallocate(std::__1::allocator<std::__1::__tree_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*> >&, std::__1::__tree_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*>*, unsigned long) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:1443
#6 0x0000000100002654 in std::__1::__tree<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::destroy(std::__1::__tree_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void*>*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tree:1446
#7 0x0000000100002551 in ~__tree at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tree:1433
#8 0x00000001000024f5 in ~__tree at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tree:1432
#9 0x00000001000024d5 in ~set at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/set:398
#10 0x0000000100002325 in ~set at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/set:398
#11 0x00000001000022f5 in ~SmallSet at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/SmallSet.h:31
#12 0x00000001000022c5 in ~SmallSet at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/SmallSet.h:31
#13 0x000000010000229e in ~SetVector at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/SetVector.h:37
#14 0x0000000100001de5 in ~SetVector at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/SetVector.h:37
#15 0x0000000100001d55 in ~HeaderSearchOptions at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/clang/Lex/HeaderSearchOptions.h:45
#16 0x0000000100001d25 in ~HeaderSearchOptions at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/clang/Lex/HeaderSearchOptions.h:45
#17 0x0000000100001cf3 in llvm::RefCountedBase<clang::HeaderSearchOptions>::Release() const at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/IntrusiveRefCntPtr.h:54
#18 0x0000000100001c45 in llvm::IntrusiveRefCntPtrInfo<clang::HeaderSearchOptions>::release(clang::HeaderSearchOptions*) at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/IntrusiveRefCntPtr.h:89
#19 0x0000000100001c1d in llvm::IntrusiveRefCntPtr<clang::HeaderSearchOptions>::release() at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/IntrusiveRefCntPtr.h:178
#20 0x0000000100001bd1 in ~IntrusiveRefCntPtr at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/IntrusiveRefCntPtr.h:148
#21 0x0000000100001315 in ~IntrusiveRefCntPtr at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/llvm/ADT/IntrusiveRefCntPtr.h:148
#22 0x0000000100001297 in ~CompilerInvocationBase at /Users/juancn/Downloads/clang+llvm-3.4.1-x86_64-apple-darwin10.9/include/clang/Frontend/CompilerInvocation.h:52
#23 0x0000000100254435 in clang::CompilerInstance::setInvocation(clang::CompilerInvocation*) ()
#24 0x0000000100000ea4 in main at /Users/juancn/projects/clangjit/clangjit/clangjit/main.cpp:7
What I don't understand is why setInvocation() is calling the destructor on CompilerInvocationBase which seems to be the reason of the failure (my C++ is a bit rusty, so it's quite likely that I missing something obvious).
UPDATE: I just found that just deleting the object causes the issue:
CompilerInvocation* CI = new CompilerInvocation;
delete CI;
So it looks like a bug in Clang. I still haven't found a way to work around it.

I figured it out (sort of). I was linking to clang binaries for OSX (clang+llvm-3.4.1-x86_64-apple-darwin10.9) but it seems something was off with them.
I rebuilt Clang + LLVM from scratch and used the locally built libraries instead. That solved the issue.

Related

Leaking memory when C++ ODBC app connects to Redshift DB

We are developing Linux service application based on Ubuntu 22.04 and C++20 and the application connects to AWS Redshift service using unixODBC.
In debug build we are running ASAN with enabled LeakSanitizer, that records memory leak originating from SQLDriverConnect.
I have the following (latest & greatest that time when the problem discovered) driver installed:
https://s3.amazonaws.com/redshift-downloads/drivers/odbc/1.4.59.1000/AmazonRedshiftODBC-64-bit-1.4.59.1000-1.x86_64.deb
I also tried with an earlier version of Redshift ODBC driver too.
Running the following command line, I can constantly reproduce the following memory leak report:
ASAN_OPTIONS=verbosity=1:fast_unwind_on_malloc=0:check_initialization_order=1 ./memleak
The minimal example to reproduce the program:
#include <iostream>
#include <sql.h>
#include <sqlext.h>
#include <string>
int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv_char[], __attribute__((unused)) char* env_char[]) {
SQLHENV env = nullptr;
std::cerr << SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env) << std::endl;
std::cerr << SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<SQLPOINTER>(SQL_OV_ODBC3), 0) << std::endl;
SQLHDBC dbc = nullptr;
std::cerr << SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc) << std::endl;
std::cerr << SQLSetConnectAttr(dbc, SQL_ATTR_AUTOCOMMIT, reinterpret_cast<SQLPOINTER>(true), 0) << std::endl;
std::string connectionString = "Driver={Amazon Redshift (x64)};Server=<...>;Port=5439;Database=<...>;UID=<...>;PWD=<...>";
std::cerr << SQLDriverConnect(dbc, nullptr, (SQLCHAR*)connectionString.c_str(), connectionString.size(), nullptr, 0, nullptr, SQL_DRIVER_COMPLETE) << std::endl;
std::cerr << SQLDisconnect(dbc) << std::endl;
std::cerr << SQLFreeHandle(SQL_HANDLE_DBC, dbc) << std::endl;
std::cerr << SQLFreeHandle(SQL_HANDLE_ENV, env) << std::endl;
return 0;
}
The ASAN log output:
==30839==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 72 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3ea9db8 in __interceptor_calloc (/.../build-...-Clang_14-Debug/.../memleak+0xa3db8) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fa8b4f8e (<unknown module>)
#2 0x7f21fa8b534c (<unknown module>)
#3 0x7f21fb606f19 in Simba::ODBC::ODBCIniReader::GetKeyValuePairs(Simba::ODBC::ODBCIniReader::Source, Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3bf19)
#4 0x7f21fb6093fe in Simba::ODBC::ConnectionSettings::LoadFromOdbcIni(Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3e3fe)
#5 0x7f21fb609a3a in Simba::ODBC::ConnectionSettings::LoadODBCSettings() (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3ea3a)
#6 0x7f21fb60a427 in Simba::ODBC::ConnectionSettings::LoadSettings(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f427)
#7 0x7f21fb60a764 in Simba::ODBC::ConnectionSettings::ConnectionSettings(Simba::Support::simba_wstring const&, Simba::ODBC::Connection&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f764)
#8 0x7f21fb601c24 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c24)
#9 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#10 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#11 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#12 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#13 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#14 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#15 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3ea9bce in malloc (/.../build-...-Clang_14-Debug/.../memleak+0xa3bce) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fbea8967 in operator new(unsigned long) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x13dd967)
#2 0x7f21fb1c2538 in Simba::Support::AttributeData::MakeNewWStringAttributeData(Simba::Support::simba_wstring*) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x6f7538)
#3 0x7f21fad8b198 in Simba::PostgreSQLODBC::PGOConnection::HandleConnect(std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > > const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x2c0198)
#4 0x7f21fb68eb2e in Simba::DriverSupport::DSCommonConnection::Connect(Simba::DSI::ConnectionSettingsRequest const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xbc3b2e)
#5 0x7f21fb5fbcfc in Simba::ODBC::Connection::CompleteConnection(Simba::ODBC::ConnectionSettings&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb30cfc)
#6 0x7f21fb601c75 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c75)
#7 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#8 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#9 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#10 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#11 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#12 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#13 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#14 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Indirect leak of 176 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3ea9bce in malloc (/.../build-...-Clang_14-Debug/.../memleak+0xa3bce) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fb131fa6 in sbicu_58__sb64::UnicodeString::allocate(int) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x666fa6)
#2 0x7f21fb132307 in sbicu_58__sb64::UnicodeString::UnicodeString(int, int, int) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x667307)
#3 0x7f21fb2165d4 in Simba::Support::simba_wstring::GetWritableBuffer(int) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x74b5d4)
#4 0x7f21fb23a712 in Simba::Support::WideStringConverter::ConvertToWString(unsigned char const*, int, Simba::Support::EncodingType, Simba::Support::simba_wstring&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x76f712)
#5 0x7f21fad8b190 in Simba::PostgreSQLODBC::PGOConnection::HandleConnect(std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > > const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x2c0190)
#6 0x7f21fb68eb2e in Simba::DriverSupport::DSCommonConnection::Connect(Simba::DSI::ConnectionSettingsRequest const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xbc3b2e)
#7 0x7f21fb5fbcfc in Simba::ODBC::Connection::CompleteConnection(Simba::ODBC::ConnectionSettings&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb30cfc)
#8 0x7f21fb601c75 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c75)
#9 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#10 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#11 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#12 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#13 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#14 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#15 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Indirect leak of 64 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3ea9bce in malloc (/.../build-...-Clang_14-Debug/.../memleak+0xa3bce) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fb0cf2c8 in sbicu_58__sb64::UMemory::operator new(unsigned long) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x6042c8)
#2 0x7f21fb213d90 in Simba::Support::simba_wstring::simba_wstring(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x748d90)
#3 0x7f21fb1c25d0 in Simba::Support::AttributeData::MakeNewWStringAttributeData(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x6f75d0)
#4 0x7f21fad8b198 in Simba::PostgreSQLODBC::PGOConnection::HandleConnect(std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > > const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x2c0198)
#5 0x7f21fb68eb2e in Simba::DriverSupport::DSCommonConnection::Connect(Simba::DSI::ConnectionSettingsRequest const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xbc3b2e)
#6 0x7f21fb5fbcfc in Simba::ODBC::Connection::CompleteConnection(Simba::ODBC::ConnectionSettings&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb30cfc)
#7 0x7f21fb601c75 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c75)
#8 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#9 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#10 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#11 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#12 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#13 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#14 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#15 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3e94933 in __interceptor___strdup (/.../build-...-Clang_14-Debug/.../memleak+0x8e933) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fa8b4fa8 (<unknown module>)
#2 0x7f21fa8b534c (<unknown module>)
#3 0x7f21fb606f19 in Simba::ODBC::ODBCIniReader::GetKeyValuePairs(Simba::ODBC::ODBCIniReader::Source, Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3bf19)
#4 0x7f21fb6093fe in Simba::ODBC::ConnectionSettings::LoadFromOdbcIni(Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3e3fe)
#5 0x7f21fb609a3a in Simba::ODBC::ConnectionSettings::LoadODBCSettings() (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3ea3a)
#6 0x7f21fb60a427 in Simba::ODBC::ConnectionSettings::LoadSettings(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f427)
#7 0x7f21fb60a764 in Simba::ODBC::ConnectionSettings::ConnectionSettings(Simba::Support::simba_wstring const&, Simba::ODBC::Connection&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f764)
#8 0x7f21fb601c24 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c24)
#9 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#10 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#11 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#12 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#13 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#14 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#15 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3ea9bce in malloc (/.../build-...-Clang_14-Debug/.../memleak+0xa3bce) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fbea8967 in operator new(unsigned long) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x13dd967)
#2 0x7f21fb1c25c2 in Simba::Support::AttributeData::MakeNewWStringAttributeData(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x6f75c2)
#3 0x7f21fad8b198 in Simba::PostgreSQLODBC::PGOConnection::HandleConnect(std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > > const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0x2c0198)
#4 0x7f21fb68eb2e in Simba::DriverSupport::DSCommonConnection::Connect(Simba::DSI::ConnectionSettingsRequest const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xbc3b2e)
#5 0x7f21fb5fbcfc in Simba::ODBC::Connection::CompleteConnection(Simba::ODBC::ConnectionSettings&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb30cfc)
#6 0x7f21fb601c75 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c75)
#7 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#8 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#9 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#10 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#11 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#12 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#13 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#14 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3e94933 in __interceptor___strdup (/.../build-...-Clang_14-Debug/.../memleak+0x8e933) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fa8b4fb8 (<unknown module>)
#2 0x7f21fa8b534c (<unknown module>)
#3 0x7f21fb606f19 in Simba::ODBC::ODBCIniReader::GetKeyValuePairs(Simba::ODBC::ODBCIniReader::Source, Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3bf19)
#4 0x7f21fb6093fe in Simba::ODBC::ConnectionSettings::LoadFromOdbcIni(Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3e3fe)
#5 0x7f21fb609a3a in Simba::ODBC::ConnectionSettings::LoadODBCSettings() (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3ea3a)
#6 0x7f21fb60a427 in Simba::ODBC::ConnectionSettings::LoadSettings(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f427)
#7 0x7f21fb60a764 in Simba::ODBC::ConnectionSettings::ConnectionSettings(Simba::Support::simba_wstring const&, Simba::ODBC::Connection&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f764)
#8 0x7f21fb601c24 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c24)
#9 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#10 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#11 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#12 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#13 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#14 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#15 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3e94933 in __interceptor___strdup (/.../build-...-Clang_14-Debug/.../memleak+0x8e933) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fa8b4fdf (<unknown module>)
#2 0x7f21fa8b534c (<unknown module>)
#3 0x7f21fb606f19 in Simba::ODBC::ODBCIniReader::GetKeyValuePairs(Simba::ODBC::ODBCIniReader::Source, Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3bf19)
#4 0x7f21fb6093fe in Simba::ODBC::ConnectionSettings::LoadFromOdbcIni(Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3e3fe)
#5 0x7f21fb609a3a in Simba::ODBC::ConnectionSettings::LoadODBCSettings() (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3ea3a)
#6 0x7f21fb60a427 in Simba::ODBC::ConnectionSettings::LoadSettings(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f427)
#7 0x7f21fb60a764 in Simba::ODBC::ConnectionSettings::ConnectionSettings(Simba::Support::simba_wstring const&, Simba::ODBC::Connection&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f764)
#8 0x7f21fb601c24 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c24)
#9 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#10 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#11 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#12 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#13 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#14 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#15 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x55a8d3e94933 in __interceptor___strdup (/.../build-...-Clang_14-Debug/.../memleak+0x8e933) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
#1 0x7f21fa8b502f (<unknown module>)
#2 0x7f21fa8b534c (<unknown module>)
#3 0x7f21fb606f19 in Simba::ODBC::ODBCIniReader::GetKeyValuePairs(Simba::ODBC::ODBCIniReader::Source, Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3bf19)
#4 0x7f21fb6093fe in Simba::ODBC::ConnectionSettings::LoadFromOdbcIni(Simba::Support::simba_wstring const&, std::map<Simba::Support::simba_wstring, Simba::Support::Variant, Simba::Support::simba_wstring::CaseInsensitiveComparator, std::allocator<std::pair<Simba::Support::simba_wstring const, Simba::Support::Variant> > >&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3e3fe)
#5 0x7f21fb609a3a in Simba::ODBC::ConnectionSettings::LoadODBCSettings() (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3ea3a)
#6 0x7f21fb60a427 in Simba::ODBC::ConnectionSettings::LoadSettings(Simba::Support::simba_wstring const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f427)
#7 0x7f21fb60a764 in Simba::ODBC::ConnectionSettings::ConnectionSettings(Simba::Support::simba_wstring const&, Simba::ODBC::Connection&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb3f764)
#8 0x7f21fb601c24 in Simba::ODBC::ConnectionState2::SQLDriverConnectW(Simba::ODBC::Connection*, void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb36c24)
#9 0x7f21fb5f5220 in Simba::ODBC::Connection::SQLDriverConnectW(void*, wchar_t*, short, wchar_t*, short, short*, unsigned short) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xb2a220)
#10 0x7f21fb5b3133 in Simba::ODBC::SQLDriverConnectTask<false>::DoSynchronously(Simba::ODBC::Connection&, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters const&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae8133)
#11 0x7f21fb5c6e5a in short DoTask<Simba::ODBC::SQLDriverConnectTask<false> >(char const*, void*, Simba::ODBC::SQLDriverConnectTask<false>::TaskParameters&) (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xafbe5a)
#12 0x7f21fb5b35e4 in SQLDriverConnect (/opt/amazon/redshiftodbc/lib/64/libamazonredshiftodbc64.so+0xae85e4)
#13 0x7f22018555a6 in SQLDriverConnect /bamboo/unixODBC-2.3.7/DriverManager/SQLDriverConnect.c:1376
#14 0x55a8d3ee7a06 in main /.../.../.../.../Memleak.cpp:18:18
#15 0x7f220119a082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
#16 0x55a8d3e274bd in _start (/.../build-...-Clang_14-Debug/.../memleak+0x214bd) (BuildId: 850d8cc71ac471cad6a45c89d7d3d2ac413d856f)
SUMMARY: AddressSanitizer: 353 byte(s) leaked in 9 allocation(s).

Google Filament rendering engine segmentation fault

I am attempting to compile the sample app "Suzanne" from the Filament library, by statically linking to the appropriate libraries. Both the sample app and libraries have been compiled from the latest source code. I am compiling with clang++.
However, when I compile and run the app, I get a segmentation fault. valgrind gives the following output:
==31202== Process terminating with default action of signal 11 (SIGSEGV)
==31202== Access not within mapped region at address 0x8
==31202== at 0x46A485: size (__hash_table:809)
==31202== by 0x46A485: bucket_count (__hash_table:1197)
==31202== by 0x46A485: std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, void*>*> std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >::find<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (__hash_table:2334)
==31202== by 0x461CA7: find (unordered_map:1205)
==31202== by 0x461CA7: image::KtxBundle::getMetadata(char const*, unsigned long*) const (KtxBundle.cpp:274)
==31202== by 0x463D26: image::KtxBundle::getSphericalHarmonics(filament::math::details::TVec3<float>*) (KtxBundle.cpp:290)
==31202== by 0x420E69: IBL::loadFromKtx(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (in /home/joel/Documents/KiwiTest/filament-suzanne/out/suzanne)
==31202== by 0x42162D: IBL::loadFromDirectory(utils::Path const&) (in /home/joel/Documents/KiwiTest/filament-suzanne/out/suzanne)
==31202== by 0x41A41C: FilamentApp::loadIBL(Config const&) (in /home/joel/Documents/KiwiTest/filament-suzanne/out/suzanne)
==31202== by 0x415D19: FilamentApp::run(Config const&, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, unsigned long, unsigned long) (in /home/joel/Documents/KiwiTest/filament-suzanne/out/suzanne)
==31202== by 0x40A1D4: main (in /home/joel/Documents/KiwiTest/filament-suzanne/out/suzanne)
==31202== If you believe this happened as a result of a stack
==31202== overflow in your program's main thread (unlikely but
==31202== possible), you can try to increase the size of the
==31202== main thread stack using the --main-stacksize= flag.
==31202== The main thread stack size used in this run was 8388608.
Any thoughts on what could be causing this and what I could do to resolve this would be greatly appreciated.
Error resolved (courtesy of TheGoldKnight23): The header files in use were outdated.

googlemock segmentation fault with simple case of EXPECT_CALL

Mock class:
class MockManagerForClient {
public:
MOCK_CONST_METHOD0(GetEngine, std::shared_ptr<engine::Engine>());
MOCK_METHOD1(RemoveClient, void(std::string const& clientId));
virtual ~MockManagerForClient() = default;
};
Test case:
TEST(ClientTest, Login) {
NiceMock<MockManagerForClient> manager;
EXPECT_CALL(manager, RemoveClient(_)).Times(1);
manager.RemoveClient("1");
}
stack capture in gdb:
Catchpoint 1 (signal SIGSEGV), 0x00005555557266f6 in testing::Cardinality::ConservativeUpperBound() const ()
(gdb) bt
#0 0x00005555557266f6 in testing::Cardinality::ConservativeUpperBound() const ()
#1 0x00005555557216c9 in testing::internal::ExpectationBase::CheckActionCountIfNotDone() const ()
#2 0x00005555556ba810 in testing::internal::TypedExpectation<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::ShouldHandleArguments(std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> const&) const (this=0x555555a2c8a0, args=std::tuple containing = {...})
at /home/phillip/.conan/data/googletest/1.8.1/phillip/stable/package/efbe354690ef83824a1e98c7a6076b7ab63bc1b3/include/gmock/gmock-spec-builders.h:1111
#3 0x00005555556b9749 in testing::internal::FunctionMockerBase<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::FindMatchingExpectationLocked(std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> const&) const (this=0x7fffffffda00, args=std::tuple containing = {...})
at /home/phillip/.conan/data/googletest/1.8.1/phillip/stable/package/efbe354690ef83824a1e98c7a6076b7ab63bc1b3/include/gmock/gmock-spec-builders.h:1739
#4 0x00005555556b8b56 in testing::internal::FunctionMockerBase<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::UntypedFindMatchingExpectation(void const*, void const**, bool*, std::ostream*, std::ostream*) (this=0x7fffffffda00, untyped_args=0x7fffffffd8f0, untyped_action=0x7fffffffd340, is_excessive=0x7fffffffd337, what=0x7fffffffd3d0, why=0x7fffffffd560)
at /home/phillip/.conan/data/googletest/1.8.1/phillip/stable/package/efbe354690ef83824a1e98c7a6076b7ab63bc1b3/include/gmock/gmock-spec-builders.h:1701
#5 0x000055555572235d in testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void*) ()
#6 0x00005555556b56c0 in testing::internal::FunctionMockerBase<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::InvokeWith(std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>&&) (this=0x7fffffffda00, args=...) at /home/phillip/.conan/data/googletest/1.8.1/phillip/stable/package/efbe354690ef83824a1e98c7a6076b7ab63bc1b3/include/gmock/gmock-spec-builders.h:1602
#7 0x00005555556b4b75 in testing::internal::FunctionMocker<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::Invoke(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=0x7fffffffda00, a1="1") at /home/phillip/.conan/data/googletest/1.8.1/phillip/stable/package/efbe354690ef83824a1e98c7a6076b7ab63bc1b3/include/gmock/gmock-generated-function-mockers.h:101
#8 0x00005555556b46f0 in MockManagerForClient::RemoveClient (this=0x7fffffffd9b0, gmock_a1=...) at /home/phillip/projects/spiral-front/front/engine-test/src/client-impl/./mocks.hpp:33
#9 0x00005555556b3480 in ClientTest_Login_Test::TestBody (this=0x555555a2c1c0) at /home/phillip/projects/spiral-front/front/engine-test/src/client-impl/client-impl-test.cpp:43
#10 0x000055555575f371 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ()
#11 0x000055555575957b in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ()
#12 0x0000555555739298 in testing::Test::Run() ()
#13 0x0000555555739bf5 in testing::TestInfo::Run() ()
#14 0x000055555573a278 in testing::TestCase::Run() ()
#15 0x0000555555745064 in testing::internal::UnitTestImpl::RunAllTests() ()
#16 0x0000555555760519 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ()
#17 0x000055555575a35f in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ()
#18 0x0000555555743aec in testing::UnitTest::Run() ()
#19 0x00005555556fe830 in RUN_ALL_TESTS () at /home/phillip/.conan/data/googletest/1.8.1/phillip/stable/package/efbe354690ef83824a1e98c7a6076b7ab63bc1b3/include/gtest/gtest.h:2341
#20 0x00005555556fe23c in main (argc=1, argv=0x7fffffffe148) at /home/phillip/projects/spiral-front/front/engine-test/src/main.cpp:7
I have tried several hours and no idea why. I have several others mock class, all works find. The most different of this MockManagerForClient is RemoveClient is return void.
I finally fixed the problem after 2 days. Just like other peoples crash situation, it is due project's compile flags not same as googletest.
My environment is Ubuntu 18.04 with g++ 7.4.0.
To make googletest works with c++11 standard, I use master branch of https://github.com/google/googletest. Build googletest with cmake and check cmake generation file: flags.make
googletest use -std=c++11, will my project use -std=gun++11. So adding following cmake definitions:
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Fixing compile errors due to using c++14 features. Well then the crash issue still there.
Extra compile flags not in my project is: -g -Wall -Wshadow -Werror -Wno-error=dangling-else -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
After adding them to my project's CMakeLists.txt and fixing compile errors. googletest crash issue finally gone.

How can I debug Boost by viewing the file after precompilation?

I'm getting a very weird bug when defining a test suite with boost like this:
BOOST_AUTO_TEST_SUITE(zerocoin_implementation_tests)
The error looks like this:
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
Here's the relevant backtrace:
#5 0x00007ffff5ce6fe8 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff5ce2875 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007ffff5d7c949 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8 0x00007ffff70afe15 in boost::unit_test::test_unit::test_unit(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::test_unit_type) () from /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.65.1
#9 0x00007ffff70b0456 in boost::unit_test::test_suite::test_suite(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long) () from /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.65.1
#10 0x00007ffff70b0612 in boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::decorator::collector&) ()
from /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.65.1
From what I can tell, this has to do with Boost trying to create a max length string. I'd like to see exactly what it is doing. What's the best way of expanding boost macros to see the pre-compiled version?
Side Note
Weirdly, if I change the line very slightly to:
BOOST_AUTO_TEST_SUITE(zerocsoin_implementation_tests)
I get the following error:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
And backtrace:
#6 0x00007ffff5ce7594 in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007ffff70afe15 in boost::unit_test::test_unit::test_unit(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::test_unit_type) () from /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.65.1
#8 0x00007ffff70b0456 in boost::unit_test::test_suite::test_suite(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long) () from /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.65.1
#9 0x00007ffff70b0612 in boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::decorator::collector&) ()
from /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.65.1
The source code for the file (and the rest of the project) can be found here: https://github.com/phoreproject/Phore/blob/segwit/src/test/zerocoin_implementation_tests.cpp
Diff that probably caused the bug: https://github.com/phoreproject/phore/compare/master...segwit#diff-bb4f094cc636d668944ed6af9b72c0d9
Two approaches:
Exception Breakpoints
Just start the test in the debugger and catch the exception.
In gdb you could do
(gdb) catch throw
Catchpoint 2 (throw)
which act like a general breakpoint. Visual Studio has a Manage Exeptions dialog.¹
Boost Test Breakpoints
For debugging Boost Test I like to set a break at the test_method member of the specific test case class I want to break at. E.g. with a test_runner that has a few nested suites like:
./test_runner --list_content
import*
utility*
xml*
xml_utilities*
child_text_test*
loggable_xml_path_test*
And we run these 3 tests like:
./test_runner -t import/utility/xml
Running 3 test cases...
*** No errors detected
To debug them with gdb I'd do
gdb ./test_runner
start -t import/utility/xml
Which stops at main, then I type:
break import::utility::xml
Auto completion helps, so to get the exact names, you can just pick from the completions:
xml
xml::as_element(xmlpp::Node const&)
xml::attr_value(xmlpp::Element const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
xml::attr_value(xmlpp::Node const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
xml::child_text[abi:cxx11](xmlpp::Element const&, char const*)
xml::child_text_test
xml::child_text_test::test_method()
xml::child_text_test_invoker()
xml::child_text_test_registrar62
xml::end_suite94_registrar94
xml::first_child(xmlpp::Element const&, char const*)
xml::get_content[abi:cxx11](xmlpp::Element const&)
xml::get_content[abi:cxx11](xmlpp::Node const*)
xml::is_attr_value(xmlpp::Node const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
xml::loggable_xml_path[abi:cxx11](xmlpp::Node const&)
xml::loggable_xml_path_test
xml::loggable_xml_path_test::test_method()
xml::loggable_xml_path_test_invoker()
xml::loggable_xml_path_test_registrar77
xml::trace_xml(xmlpp::Element const&, LogSource::LogTx)
xml::trace_xml_formatted(xmlpp::Element const&, LogSource::LogTx)
xml::xml_registrar20
xml::xml_utilities
xml::xml_utilities::test_method()
xml::xml_utilities_invoker()
xml::xml_utilities_registrar22
Pick the ones named test_method(), e.g.
break import::utility::xml::child_text_test::test_method()
Breakpoint 2 at 0x730762: file /path/src/import/utility/xml_tests.cpp, line 62.
Now you can continue execution and the debugger will automatic pause execution at the start of your unit test.
¹ see also
Make Visual Studio break on User (std::exception) Exceptions?
How do I make VC++'s debugger break on exceptions?

Uninitialised value was created by a heap allocation: Unordered_map

SOLUTION: I can have huge strings, then I have to reserve memory for them. Instead of use string I use char pointer in hash table and therefore I reserve the appropriate memory for my hash table keys.
PROBLEM:
I'm sorry if the question already made, but I could not find any answer that helped me.
I've the following code:
EDIT (the main loop of the problematic function for Valgrind)
i = 0;
wordPos = 0;
for (; it != end; ++it,i++){
// I want to ignore this element on purpose
if (i == 1) continue;
bool isscript;
string tag(it->tagName());
convertToLower(tag);
if (it->isTag()==1){
if (tag=="script") isscript = true;
else isscript = false;
}
if (it->isComment()==0 && it->isTag()==0 && isscript==0){
wordlist.clear();
tokenize(it->text(),wordlist);
int ii = 0;
vector<string>::iterator it_palavras = wordlist.begin();
vector<string>::iterator it_words = wordlist.begin();
int ii = 0;
while(ii<wordlist.size()){
string word(wordlist[ii]);
convertToLower(word);
wordsPos++;
if (voc.find(word) == voc.end()){
voc[word] = countwords;
voc_inv[countwords] = words;
term_pos[countwords] = new vector<int>();
term_pos[countwords]->push_back(wordpos);
countwords++;
}else{
if (term_pos.find(voc[word]) == term_pos.end())
term_pos[voc[word]] = new vector<int>();
term_pos[voc[word]]->push_back(wordpos);
}
ii++;
}
}
The type of voc is unordered_map, but when I run valgrind in my code there is the following message:
EDIT Now I'm pasting the complete error with the flag --track-origins=yes.
EDIT 2 Now I'm pasting the complete error with the flag --—dsymutil=yes.
==21036== Use of uninitialised value of size 8
==21036== at 0x4201FF: _platform_memcmp (in /usr/lib/system/libsystem_platform.dylib)
==21036== by 0x10001F10D: std::__1::__hash_iterator<std::__1::__hash_node<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int>, void*>*> std::__1::__hash_table<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int>, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int> > >::find<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (string:642)
==21036== by 0x10000358F: Colecao::ler_arvore_dom(tree<htmlcxx::HTML::Node, std::__1::allocator<tree_node_<htmlcxx::HTML::Node> > >, int, std::__1::unordered_map<int, std::__1::vector<int, std::__1::allocator<int> >, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<int const, std::__1::vector<int, std::__1::allocator<int> > > > >&) (colecao.cpp:135)
==21036== by 0x100002A19: Colecao::ler(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) (colecao.cpp:73)
==21036== by 0x100001781: main (index.cpp:47)
==21036== Uninitialised value was created by a heap allocation
==21036== at 0x70AB: malloc (in /usr/local/Cellar/valgrind/HEAD/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==21036== by 0x7528D: operator new(unsigned long) (in /usr/lib/libc++.1.dylib)
==21036== by 0x77E12: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long) (in /usr/lib/libc++.1.dylib)
==21036== by 0x10001A0FF: std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<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, int> > >::__construct_node(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (memory:1505)
==21036== by 0x10000838D: std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<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, int> > >::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (unordered_map:1209)
==21036== by 0x100003835: Colecao::ler_arvore_dom(tree<htmlcxx::HTML::Node, std::__1::allocator<tree_node_<htmlcxx::HTML::Node> > >, int, std::__1::unordered_map<int, std::__1::vector<int, std::__1::allocator<int> >, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<int const, std::__1::vector<int, std::__1::allocator<int> > > > >&) (colecao.cpp:139)
==21036== by 0x100002A19: Colecao::ler(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) (colecao.cpp:73)
==21036== by 0x100001781: main (index.cpp:47)
When I run the code in a huge amount of data I get segmentation fault, and I think it is because of this Valgrind error.
I don't think I need to reserve space for string in unordered_map, then I figured out that is something in word variable constructor. When I initialize word with a static string (for instance, word("test")), Valgrind stops to complain.
I don't know how to fix this string/unordered_map/memory issue.
EDIT: GDB didn't help me. The segmentation fault is only when I use huge amount of data and then huge amount of memory. The only thing GDB give me is Segmentation Fault and memory address nothing more. Valgrind gave me a more complete message.
This might actually be a problem between Valgrind and the memcmp() implementation of your platform (Mac OS X I suppose?).
The uninitialized value in your application supposedly comes from a malloc() call in std::string constructor, the latter of which is unlikely to "create" uninitialized memory on its own. So my guess would be that malloc() allocates a bit more memory than necessary (aligned to 8 bytes maybe), and _platform_memcmp() also takes these bytes into account. System libraries often have highly-optimized implementations of such functions (memcpy, memcmp, strcpy...). As Valgrind often has trouble with these optimizations, it provides own replacement functions (in mc_replace_strmem.c).
Maybe Valgrind lacks these replacements for OS X memcmp(), or your Valgrind version is too old? Also, there might be a setup problem with your system which prevents Valgrind from detecting the memcmp() function at runtime (I'm not familiar with OS X, but maybe you need some kind of debug info for your system libraries).
So, some questions:
are you running the latest Valgrind version? If not, upgrade it.
what OS X version are you using exactly?
does the problem disappear if you disable optimizations when compiling your application?
If this doesn't help, you might want to ask at the Valgrind users mailing list (http://valgrind.org/support/mailing_lists.html) for this specific problem.
Btw. it's pretty difficult to analyze the Valgrind backtraces without any line numbers. See Debugging Symbols Lost When Linking? for a suggestion to get line number info in the backtraces (in short: add "--dsymutil=yes" to Valgrind command line - but check out the notes for this option in http://valgrind.org/docs/manual/manual-core.html#manual-core.erropts first).