You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Alan Conway <ac...@redhat.com> on 2009/12/02 16:48:26 UTC

Global init/shutdown in clients [was Re: Why is qpid::sys::ssl::shutdownNSS being called in a global destructor?]

On 12/02/2009 10:39 AM, Andrew Stitcher wrote:
> On Tue, 2009-12-01 at 16:34 -0500, Alan Conway wrote:
>> ...I'm getting this core dump on exit from the cluster_tests in a cmake build:
>>
>> #0  0x00000038e0075bb8 in malloc_consolidate () from /lib64/libc.so.6
>> #1  0x00000038e0078022 in _int_malloc () from /lib64/libc.so.6
>> #2  0x00000038e0079fe8 in calloc () from /lib64/libc.so.6
>> #3  0x00000031cee14463 in ?? () from /lib64/libnspr4.so
>> #4  0x00000031cee1aeff in ?? () from /lib64/libnspr4.so
>> #5  0x00000031cee2865d in PR_GetCurrentThread () from /lib64/libnspr4.so
>> #6  0x00000031cee1a397 in PR_SetError () from /lib64/libnspr4.so
>> #7  0x00000031cfa1863d in NSS_Shutdown () from /lib64/libnss3.so
>> #8  0x00007f5f94296689 in qpid::sys::ssl::shutdownNSS () at
>> /home/aconway/qpid/qpid/cpp/src/qpid/sys/ssl/util.cpp:115
>> #9  0x00007f5f934d5607 in qpid::client::(anonymous
>> namespace)::StaticInit::~StaticInit (this=0x38e0369e80, __in_chrg=<value
>> optimized out>) at /home/aconway/qpid/qpid/cpp/src/qpid/client/SslConnector.cpp:163
>> #10 0x00000038e0036bc0 in __cxa_finalize () from /lib64/libc.so.6
>> #11 0x00007f5f934d5556 in __do_global_dtors_aux () from
>> /home/aconway/qpid/qpid/cmake/src/sslconnector.so
>> #12 0x0000000000000000 in ?? ()
>>
>> This looks suspect to me, doing anything of any complexity in a static
>> destructor is dangerous, unless the NSS library specifically states that its
>> safe to shutdown this way.
>
> I'd tend to agree - perhaps this should run on module unload - oh wait -
> we don't have any way except static destruction to indicate module
> unload.
>

That seems like something we should fix. How about requiring the user to declare 
a QpidClient object at the start of main() which must stay in scope till end of 
main() giving us a place to hang our global de-initialization? That would also 
give us a place where the user could specify client configuration as an 
alternative to relying exclusively on environment variables.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org