I am writing a text-to-speech loadable module for the open source
telephony server Freeswitch, using the new AWS Polly text-to-speech
service.  The AWS C++ SDK is C++11, templatized, etc., and I am wrapping
it in C with calls to factory methods returning opaque pointers to
objects.  I am not actually executing any AWS functions at the moment,
just the static allocation of these two variables that set up the SDK
and the client.

static Aws::SDKOptions options;
static Aws::Client::ClientConfiguration config;

The rest of my Freeswitch module code is stubbed out, and makes no AWS
calls.  When I start and stop Freeswitch, the stub Polly module loads
and unloads.  At server exit, I get a free() error.  After recompiling
everything with -O0, I get this single invalid output from valgrind:

==5892== Invalid free() / delete / delete[] / realloc()
==5892==    at 0x4C29E90: free (vg_replace_malloc.c:473)
==5892==    by 0xF467A9D: Aws::Allocator<char>::deallocate(char*, unsigned 
long) (AWSAllocator.h:74)
==5892==    by 0xF467778: std::basic_string<char, std::char_traits<char>, 
Aws::Allocator<char> >::_Rep::_M_destroy(Aws::Allocator<char> const&) 
(basic_string.tcc:449)
==5892==    by 0xF4674F3: std::basic_string<char, std::char_traits<char>, 
Aws::Allocator<char> >::_Rep::_M_dispose(Aws::Allocator<char> const&) 
(basic_string.h:249)
==5892==    by 0xF467386: std::basic_string<char, std::char_traits<char>, 
Aws::Allocator<char> >::~basic_string() (basic_string.h:547)
==5892==    by 0xF46706F: 
Aws::Client::ClientConfiguration::~ClientConfiguration() 
(ClientConfiguration.h:48)
==5892==    by 0x68B9B28: __run_exit_handlers (exit.c:82)
==5892==    by 0x68B9B74: exit (exit.c:104)
==5892==    by 0x68A3B4B: (below main) (libc-start.c:321)
==5892==  Address 0xf95f6a0 is in the BSS segment of 
/usr/local/lib/libaws-cpp-sdk-core.so
==5892== 
==5892== 

I got the glibc source for my Linux and the last line of libc-start.c is
line 321, the return statement from main().

There are a bunch of small allocation errors in the rest of Freeswitch,
but no more "Invalid free/delete/delete[]/realloc()" errors.  I also
wrote a minimal dlopen/dlsym/dlclose main program to exercise the
loadable module, and got no free() errors from the static destructor,
though the build systems are somewhat different from my toy main and the
entire Freeswitch server.

The AWS C++ SDK has a flexible memory allocation system, but I am not
using any of that and thus it defaults to the system built in
malloc/free/new/delete.

I don't understand the last line:

Address 0xf95f6a0 is in the BSS segment of /usr/local/lib/libaws-cpp-\
sdk-core.so

Is there anything unusual in the trace?  How do I use this to figure out
where/why the free() error is happening?

Thanks!

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to