[botan-devel] Valgrind issue

Jack Lloyd lloyd at randombit.net
Tue Sep 20 12:09:50 EDT 2011


Hi,

From the backtrace, it looks like you are not creating a
LibraryInitializer object, so the global state which is created
implicitly is never destroyed. Options are:

In main(), create a LibraryInitializer object before calling any other
functions in the library.. Its destructor will clean up the state.

Call LibraryInitializer::deinitialize at shutdown/exit (basically
doing manually what ~LibraryInitializer would do).

-Jack

On Tue, Sep 20, 2011 at 06:50:02AM -0400, Kacprzak, Marcin          UTCFS wrote:
> Hello!
>  
> I have a problem with Botan library.
> I'm using AES or DES encryption/decryption. It works great, however when
> I run my application using Valgrind, I get a tens of such a messages:
>  
>  ==15233== 2,831 bytes in 1 blocks are possibly lost in loss record
> 1,285 of 1,286
>  ==15233==    at 0x402569A: operator new(unsigned int)
> (vg_replace_malloc.c:255)
>  ==15233==    by 0x4233D05: std::string::_Rep::_S_create(unsigned int,
> unsigned int, std::allocator<char> const&) (in
> /usr/lib/libstdc++.so.6.0.13)
>  ==15233==    by 0x4234B10: ??? (in /usr/lib/libstdc++.so.6.0.13)
>  ==15233==    by 0x4234CF5: std::basic_string<char,
> std::char_traits<char>, std::allocator<char> >::basic_string(char
> const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13)
>  ==15233==    by 0x820BF62: Botan::(anonymous
> namespace)::set_default_dl_groups(Botan::Library_State&)
> (botan.cpp:30966)
>  ==15233==    by 0x820F4FE: Botan::Library_State::load_default_config()
> (botan.cpp:31303)
>  ==15233==    by 0x81FC1B1: Botan::Library_State::initialize(bool)
> (botan.cpp:30199)
>  ==15233==    by 0x81FB18F:
> Botan::Global_State_Management::global_state() (botan.cpp:29860)
>  ==15233==    by 0x814BCB4: Botan::Allocator::get(bool) (botan.cpp:3452)
>  ==15233==    by 0x82AD13F: Botan::MemoryRegion<unsigned
> char>::init(bool, unsigned int) (botan.h:639)
>  ==15233==    by 0x82A1EEA: Botan::SecureVector<unsigned
> char>::SecureVector(unsigned int) (botan.h:793)
>  ==15233==    by 0x8286D36: Botan::OctetString::OctetString(unsigned
> char const*, unsigned int) (botan.h:1925)
>  
> where botan.cpp is amalgamation of the whole library.
>  
> My decryption code is nothing special:
>  
>  using namespace Botan;
>  int iBytesEncrypted = _iBytesRead - _iBytesRead%8;
>  SecureVector<byte> vct;
>  char* sMsg;
>  try
>  {
>   SymmetricKey bc_key =
> OctetString(ByteTable2HexString(reinterpret_cast<unsigned
> char*>(_arrOriginalKey), KEYLENGTH));
>   Pipe dec(new Hex_Decoder, get_cipher("TripleDES/ECB/NoPadding",
> bc_key, DECRYPTION));
>   dec.process_msg(ByteTable2HexString(_mbrRequest->data(),
> iBytesEncrypted));
>   vct = dec.read_all();
>   sMsg = (char*)vct.begin();
>  }
>  catch(std::exception& e)
>  {
>   gLog.Error("Cannot decrypt message: "+string(e.what()));
>   return;
>  }
>  
> Thanks for any suggestions.
> Marcin

> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel




More information about the botan-devel mailing list