Take the 2-minute tour ×

When using the Botan::SecureVector in the following unit test:

void UnitTest()
    std::vector<byte> vbData;

    Botan::SecureVector<Botan::byte> svData(&vbData[0], vbData.size());
    CPPUNIT_ASSERT(vbData == std::vector<byte>(svData.begin(), svData.end()));

a segmentation fault occurs when trying to allocate the SecureVector as it tries to deallocate a buffer during its construction.

share|improve this question
You declare a vector called vbData and then use a vector called bbData (first letter is different). Is that potentially the error (is there a global bbData?) or is that just a typo? –  Tyler McHenry May 25 '10 at 16:06
Good catch; it was a typo. –  J. Polfer May 25 '10 at 16:09
What you are encountering here is a bug; it was found and fixed in March (but a new stable release hasn't been spun, so it's still out there). It only occurred when the library wasn't initialized, but definitely a crash is never good behavior. The initialization is necessary because SecureVector wants to be able to access a shared pooling allocator that manages locked memory. BTW, may I suggest if you run into further problems with botan to try the botan-devel mailing list - people there are friendly, know the library, and often you can get answers quickly. –  Jack Lloyd Jun 7 '10 at 22:26
@Jack Lloyd - Many thanks; I've signed onto the list. –  J. Polfer Jun 11 '10 at 1:15

1 Answer 1

up vote 3 down vote accepted

Add line:

LibraryInitializer botanInit;

to function.

This seemed to me to be odd behavior, so I figured I should post it.

share|improve this answer

Your Answer


