c++ - log4cxx: Segmentation fault in apr_pool_create_ex -


i need use log4cxx c++ project. fail understand basic setup of library. here minimal attempt:

$ cat logger.cpp  #include <log4cxx/logger.h> #include <log4cxx/propertyconfigurator.h> #include <log4cxx/helpers/properties.h>  static log4cxx::loggerptr ptr;  int main() {   log4cxx::helpers::properties prop;   prop.setproperty("log4j.rootlogger","debug, a1");   prop.setproperty("log4j.appender.a1","org.apache.log4j.consoleappender");   prop.setproperty("log4j.appender.a1.layout","org.apache.log4j.patternlayout");   prop.setproperty("log4j.appender.a1.layout.conversionpattern","%d{absolute} %-5p [%c] %m%n");   log4cxx::propertyconfigurator::configure(prop);    ptr = log4cxx::logger::getlogger("api");   log4cxx_info(ptr , "test_info");   return 0; } 

i compile using:

$ g++ -g -o logger logger.cpp -llog4cxx 

it fails with:

$ gdb ./logger [...] program received signal sigsegv, segmentation fault. 0x00007ffff5f69dc9 in apr_pool_create_ex () /lib64/libapr-1.so.0 missing separate debuginfos, use: debuginfo-install apr-1.5.1-3.fc21.x86_64 apr-util-1.5.4-1.fc21.x86_64 cyrus-sasl-lib-2.1.26-19.fc21.x86_64 expat-2.1.0-10.fc21.x86_64 libdb-5.3.28-9.fc21.x86_64 libgcc-4.9.2-6.fc21.x86_64 libstdc++-4.9.2-6.fc21.x86_64 libuuid-2.25.2-3.fc21.x86_64 log4cxx-0.10.0-17.fc21.x86_64 nspr-4.10.8-1.fc21.x86_64 nss-3.19.1-1.0.fc21.x86_64 nss-softokn-freebl-3.19.1-1.0.fc21.x86_64 nss-util-3.19.1-1.0.fc21.x86_64 openldap-2.4.40-3.fc21.x86_64 zlib-1.2.8-7.fc21.x86_64 (gdb) bt #0  0x00007ffff5f69dc9 in apr_pool_create_ex () /lib64/libapr-1.so.0 #1  0x00007ffff7b26b58 in log4cxx::helpers::pool::pool() () /lib64/liblog4cxx.so.10 #2  0x00007ffff7ae06ea in log4cxx::helpers::mutexexception::formatmessage(int) () /lib64/liblog4cxx.so.10 #3  0x00007ffff7ae0786 in log4cxx::helpers::mutexexception::mutexexception(int) () /lib64/liblog4cxx.so.10 #4  0x00007ffff7b4a310 in log4cxx::helpers::synchronized::synchronized(log4cxx::helpers::mutex const&) () /lib64/liblog4cxx.so.10 #5  0x00007ffff7b5d9c8 in log4cxx::writerappender::close() () /lib64/liblog4cxx.so.10 #6  0x00007ffff7ac979c in log4cxx::consoleappender::~consoleappender() () /lib64/liblog4cxx.so.10 #7  0x00007ffff7ac98b9 in log4cxx::consoleappender::~consoleappender() () /lib64/liblog4cxx.so.10 #8  0x00007ffff7aba247 in log4cxx::helpers::appenderattachableimpl::~appenderattachableimpl() () /lib64/liblog4cxx.so.10 #9  0x00007ffff7b0494c in log4cxx::logger::~logger() () /lib64/liblog4cxx.so.10 #10 0x00007ffff7b388b4 in log4cxx::spi::rootlogger::~rootlogger() () /lib64/liblog4cxx.so.10 #11 0x00007ffff7b0429a in log4cxx::logger::~logger() () /lib64/liblog4cxx.so.10 #12 0x00007ffff7b04429 in log4cxx::logger::~logger() () /lib64/liblog4cxx.so.10 #13 0x0000000000401d6e in log4cxx::helpers::objectptrt<log4cxx::logger>::~objectptrt (this=0x6031a0 <ptr>, __in_chrg=<optimized out>) @ /usr/include/log4cxx/helpers/objectptr.h:100 #14 0x00007ffff6e38392 in __run_exit_handlers () /lib64/libc.so.6 #15 0x00007ffff6e383e5 in exit () /lib64/libc.so.6 #16 0x00007ffff6e1efe7 in __libc_start_main () /lib64/libc.so.6 #17 0x0000000000401599 in _start () 

what fundamentally wrong using global variable logger ? make sense me have singleton pattern here.

system is: fedora 21 with:

$ rpm -qv log4cxx log4cxx-0.10.0-17.fc21.x86_64 

and:

$ g++ -v using built-in specs. collect_gcc=g++ collect_lto_wrapper=/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/lto-wrapper target: x86_64-redhat-linux configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/build/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/build/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux thread model: posix gcc version 4.9.2 20150212 (red hat 4.9.2-6) (gcc)  


Comments