I'm getting a seg fault in log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::operator=() when assigning a NULL value to delete a reference to the logger.

The actual sig fault is here, in APR:

Thread [1] (Suspended: Signal 'SIGABRT' received. Description: Aborted.)   
    13 __kernel_vsyscall()  0xffffe410   
    12 raise()  0xb7ccddf0   
    11 abort()  0xb7ccf641   
    10 apr_atomic_casptr() apr_atomic.c:376 0x080fa69c   
    9 log4cxx::helpers::ObjectPtrBase::exchange() objectptr.cpp:34 0x08071c2e   
    8 ~ObjectPtrT() objectptr.h:74 0x0804de39
    7 ~ThreadSpecificData() ThreadsHelper.cpp:115 0x08055bb2

This only seems to happen when I'm deleting my own allocated APR pool within a thread (a sub-pool of the roots), and then afterwards call the log4cxx operator= as above to remove the reference to the logger.

If I don't call apr_pool_destroy on my thread local pool then I can remove the loggers reference, but the pool never gets freed (as checked by building apr with its pool debug stuff on).

Are there any guidelines for using both log4cxx and APR within the same app? Or some pointers, examples, etc.?