[Botan-devel] Re: crashing in dso

Mayur Patel patel at coredp.com
Thu Jan 31 16:05:22 EST 2008


>I suspect this may be related to the problem described in:
>   http://gcc.gnu.org/faq.html#dso
>My best guess right now is that due to the DSO usage, two copies of
>libstdc++ are being loaded, and if/when a pointer is allocated with
>one and freed to another: boom.

I have since verified that the .so and application are using the same 
c++ library - no duplicates due to conflicting gcc/std-c versions.

>It would help if you could post the code as well as the exact invocation
>syntax you're using with GCC to build and link everything.

This is pretty much the function, which I shamelessly ripped off the 
webpage example. I verified I am calling the Library initializer before 
this with the "thread_safe" option.

bool check_message( const std::string &message, const Parameters& param, 
std::string& error )

Botan::SecureVector<Botan::byte> signature = b64Decode( param.sig );
Botan::SecureVector<Botan::byte> public_key = b64Decode( param.key );

std::auto_ptr< Botan::X509_PublicKey > key( Botan::X509::load_key( 
public_key ) );
Botan::DSA_PublicKey* dsakey = dynamic_cast< Botan::DSA_PublicKey *>( 
key.get() );
bool success = ( dsakey );
if( success )
Botan::Pipe pipe( new Botan::PK_Verifier_Filter( get_pk_verifier( 
*dsakey, "EMSA1(SHA-1)"), signature ));
std::istringstream pipeable (message,std::istringstream::in);
pipeable >> pipe;

Botan::byte result;
pipe.read( result );

success = ( result );
if( ! result )
error = "key does not appear valid";
} else
error = "failed to acquire keys";

return success;

The link line for the library that contains this function (and Botan) 
looks something like this:

/usr/bin/g++ -IBotan-1.6.3/build/include -g -DDEBUG -Wno-deprecated 
-D__GCC_VERSION=402 -fpermissive -D_GNU_SOURCE -c 
Botan-1.6.3/src/aes.cpp -o Botan-1.6.3/src/aes.o
<et. al>

/usr/bin/ar cruv libMYENCRYPT.a Botan-1.6.3/src/aes.o <et. al.>

The compile for the .so looks something like this:

/usr/bin/g++ -g -DDEBUG -Wno-deprecated -D__GCC_VERSION=402 -pipe 
-march=pentium4 -D_BOOL -DLINUX -c plugin.C -o plugin.o

/usr/bin/g++ -elf -shared -all plugin.o -lMYENCRYPT -o plugin.so

I tried various flags (-E, -Wl,-E, etc) associated with the gcc 
information you sent but so far have had no luck. I will continue poking 

This is FC4 linux, using gcc 4.0.2.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patel.vcf
Type: text/x-vcard
Size: 145 bytes
Desc: not available
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20080131/4ba1c7a1/attachment.vcf>

More information about the botan-devel mailing list