[botan-devel] Memory Leaks with Botan 1.10.5 Amalgamation (via Botan Sqlite3)

Cory Trese cory.trese at gmail.com
Sat Nov 16 12:10:52 EST 2013


Jack,

You have been such a huge help -- I really do appreciate you taking the
time to write back.

I would be very surprised to learn that Botan contained a memory leak as
you defined it -- you're survived Valgrind!

> The other two, related to Pooling_Allocator and a map<string,string>, are
both
> part of the global state which is cleaned up by the shutdown function.

I am very glad I included those because the next clue you give is *critical*
.

> From one of the tracebacks I can see that Library_State is being
allocated as a
> side effect of another operation, instead of via the LibraryInitializer
RAII
> wrapper - this is a supported option but means that no cleanup occurs
unless

In the case of botansqlite3's Codec class, the code's assumption is that it
should initialize the library when the database starts up.

What I think is happening is the result of multiple databases starting up
-- in that case botansqlite3 will call the LibraryInitializer repeatedly.

End result -- I moved Botan::LibraryInitializer calls into the game's top
level view class, and out of Codec. That seems to fix 90% of VLD's reported
leaks.

Regarding the get_pbkdf issue, I will continue that discussion on the
botansqlite3 GitHub page because that is in line with your evaluation of
that stack.

> if this is the case it is actually a leak as those pointers are owned by
the
> caller.

Thank you to Jack for responding.

Thank you to Olivier de Gaalon as well, and to the entire mailing list for
putting up with my thread.

-Cory Trese



Cory Trese

937-609-9644
http://www.tresebrothers.com/

Try Our Android Games
https://play.google.com/store/apps/developer?id=Cory+Trese


On Sat, Nov 16, 2013 at 4:00 AM, Jack Lloyd <lloyd at randombit.net> wrote:

> On Fri, Nov 15, 2013 at 10:45:13AM -0800, Cory Trese wrote:
>
> > It is also reporting a lot of memory leaks in Botan. I am hopeful that
> > there is a solution -- perhaps there is a "Botan Cleanup" call I am
> unaware
> > of?
>
> Hi Cory,
>
> LibraryInitializer::deinitialize (or ~LibraryInitializer) will clean up
> memory
> allocated internally by the library.
>
> There are not any memory leaks I'm aware of in the library, defining
> memory leak
> as allocating memory and then losing track of it so we can't free it
> later. The
> code does allocate quite a bit of memory at startup and hold it until
> shudown,
> though.
>
> Two of the traces appear that the reurn of get_pbkdf is not being deleted
> - if
> this is the case it is actually a leak as those pointers are owned by the
> caller.
>
> The other two, related to Pooling_Allocator and a map<string,string>, are
> both
> part of the global state which is cleaned up by the shutdown function.
>
> From one of the tracebacks I can see that Library_State is being allocated
> as a
> side effect of another operation, instead of via the LibraryInitializer
> RAII
> wrapper - this is a supported option but means that no cleanup occurs
> unless you
> explicitly call Library_State::deinitialize. So likely the fix to many of
> the
> leak reports is a simple
>
> Botan::LibraryInitializer botan_init;
>
> in your main function.
>
> Cheers,
>   Jack
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20131116/de17b42c/attachment.html>


More information about the botan-devel mailing list