Hi,
 
Need your valuable inputs/findings on this issue. 
Let me know if I am missing something here in the procedure. 
This is stopping us from upgrading of the log4cxx libraries to the
latest version in our application.
 
Problem Highlight:
1.    The sample program for log4cxx 0.10.0 core dump if I compile for
Solaris sparc and run.
2.    Work around is defining the variable locally - i.e. by moving the
variable (logger) declaration inside the main(). 
3.    The same program runs fine with Red hat 5.
4.    The same program runs fine if I use log4cxx-r603007 version in
both Solaris and Red Hat.
 
 
Details:
I compiled the sample log4cxx program given under "Configuration"
 section ( http://logging.apache.org/log4cxx/index.html
<http://logging.apache.org/log4cxx/index.html> ) on Solaris and its
 getting Segmentation fault during exit() of program. It could be due to
 order of constructor/destructor and exit() calls. Same program is
 working well under Red Hat Linux. I used latest release version of
log4cxx
 0.10. 
 
Here is the log:
 
sol10-116200# cat MyApp.cpp
// include log4cxx header files.
#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"
 
using namespace log4cxx;
using namespace log4cxx::helpers;
 
LoggerPtr logger(Logger::getLogger("MyApp"));
 
int main(int argc, char **argv)
{
    int result = EXIT_SUCCESS;
    try
    {
        // Set up a simple configuration that logs on the console.
        BasicConfigurator::configure();
 
        LOG4CXX_INFO(logger, "Entering application.");
        LOG4CXX_INFO(logger, "Exiting application.");
    }
    catch(Exception&)
    {
        result = EXIT_FAILURE;
    }
 
    return result;
}
sol10-116200# ls /sample/log4cxx/include /sample/log4cxx/lib
/sample/log4cxx/include:
log4cxx
 
/sample/log4cxx/lib:
apr.exp         libaprutil-1.la <http://libaprutil-1.la>
libexpat.so <http://libexpat.so> .0.1.0
aprutil.exp     libaprutil-1.so <http://libaprutil-1.so>
liblog4cxx.a
libapr-1.a      libaprutil-1.so <http://libaprutil-1.so> .0
liblog4cxx.la <http://liblog4cxx.la> 
libapr-1.la <http://libapr-1.la>      libaprutil-1.so
<http://libaprutil-1.so> .0.2.12  liblog4cxx.so <http://liblog4cxx.so> 
libapr-1.so <http://libapr-1.so>      libexpat.a      liblog4cxx.so.10
<http://liblog4cxx.so.10libapr-1.so> 
<http://liblog4cxx.so.10libapr-1.so> libapr-1.so.0       libexpat.la
<http://libexpat.la>      liblog4cxx.so.10.0.0
<http://liblog4cxx.so.10.0.0libapr-1.so> 
libapr-1.so <http://liblog4cxx.so.10.0.0libapr-1.so> .0.2.12
libexpat.so <http://libexpat.so> 
libaprutil-1.a      libexpat.so <http://libexpat.so> .0
sol10-116200#
sol10-116200#
sol10-116200#
sol10-116200# /usr/sfw/bin/g++ -I/sample/log4cxx/include MyApp.cpp -lnsl
 -lrt -lsendfile -lsocket -lpthread -L/sample/log4cxx/lib -llog4cxx
 -laprutil-1 -lapr-1 -lexpat
sol10-116200# env | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=/opt/Netscape/dist/lib
sol10-116200# LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/sample/log4cxx/lib
 export LD_LIBRARY_PATH
sol10-116200# env | grep LD_LIBRARY_PATH
LD_LIBRARY_PATH=/opt/Netscape/dist/lib:/sample/log4cxx/lib
sol10-116200# ./a.out
0 [0x1] INFO MyApp null - Entering application.
1 [0x1] INFO MyApp null - Exiting application.
Segmentation Fault - core dumped
sol10-116200# dbx a.out core
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.6' in
 your .dbxrc
Reading a.out
core file header read successfully
Reading ld.so <http://ld.so> .1
Reading libnsl.so <http://libnsl.so> .1
Reading librt.so <http://librt.so> .1
Reading libsendfile.so <http://libsendfile.so> .1
Reading libsocket.so <http://libsocket.so> .1
Reading libpthread.so <http://libpthread.so> .1
Reading liblog4cxx.so <http://liblog4cxx.so> .10
Reading libaprutil-1.so <http://libaprutil-1.so> .0
Reading libapr-1.so <http://libapr-1.so> .0
Reading libexpat.so <http://libexpat.so> .0
Reading libstdc++.so.6.0.3
Reading libm.so <http://libm.so> .2
Reading libgcc_s.so <http://libgcc_s.so> .1
Reading libc.so <http://libc.so> .1
Reading libaio.so <http://libaio.so> .1
Reading libmd.so <http://libmd.so> .1
Reading libuuid.so <http://libuuid.so> .1
Reading libc_psr.so <http://libc_psr.so> .1
[EMAIL PROTECTED] ([EMAIL PROTECTED]) program terminated by signal SEGV (no 
mapping at the fault
 address)
Current function is apr_atomic_dec32
  310       apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
(dbx) where
current thread: [EMAIL PROTECTED]
=>[1] apr_atomic_dec32(mem = 0x31d0c), line 310 in "apr_atomic.c"
  [2] log4cxx::helpers::ObjectImpl::releaseRef(this = 0x31d08), line 44
 in "objectimpl.cpp"
  [3]
 log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::~ObjectPtrT(0x221ec,
0x29c10, 0x1, 0x0, 0x4, 0xffff), at 0x1192c
  [4] __static_initialization_and_destruction_0(0x0, 0xffff,
 0xff0bcfe8, 0x0, 0xff3f42e8, 0x0), at 0x116d0
  [5] _GLOBAL__D_logger(0x110, 0x0, 0x0, 0xff, 0x0, 0x11708), at
 0x11718
  [6] __do_global_dtors_aux(0xfecf42c0, 0x0, 0x0, 0x0, 0x0,
 0xff342000), at 0x10ff8
  [7] _fini(0x1, 0x1084, 0xfebc1840, 0x0, 0xff342000, 0x1000), at
 0x117ac
  [8] _exithandle(0xfecf4540, 0xfebc16c0, 0xfecf3580, 0x34930, 0x4,
 0xffbffbb0), at 0xfec418dc
  [9] exit(0x0, 0xffbffc4c, 0xffbffc54, 0x2222c, 0xfebc16c0,
 0xfebc1700), at 0xfec301f0
(dbx) run
dbx: internal warning: td_ta_clear_event() failed -- debugger service
 failed
dbx: internal warning: td_ta_sync_tracking_enable(0) failed -- debugger
 service failed
Running: a.out
(process id 1675)
1 [0x1] INFO MyApp null - Entering application.
1 [0x1] INFO MyApp null - Exiting application.
[EMAIL PROTECTED] ([EMAIL PROTECTED]) signal SEGV (no mapping at the fault 
address) in
 apr_atomic_dec32 at line 310 in file "apr_atomic.c"
  310       apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
(dbx) where
current thread: [EMAIL PROTECTED]
=>[1] apr_atomic_dec32(mem = 0x31d0c), line 310 in "apr_atomic.c"
  [2] log4cxx::helpers::ObjectImpl::releaseRef(this = 0x31d08), line 44
 in "objectimpl.cpp"
  [3]
 log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::~ObjectPtrT(0x221ec,
0x0, 0x0, 0x0, 0xfecf42c0, 0xffff), at 0x1192c
  [4] __static_initialization_and_destruction_0(0x0, 0xffff, 0x0, 0x0,
 0xfecf42c0, 0xffff8000), at 0x116d0
  [5] _GLOBAL__D_logger(0xff000000, 0x0, 0xff000000, 0xff000000, 0x0,
 0x11708), at 0x11718
  [6] __do_global_dtors_aux(0x0, 0x3012c44a, 0xff000000, 0x0,
 0xfebb0050, 0x0), at 0x10ff8
  [7] _fini(0x1, 0x1084, 0xfeb41840, 0x0, 0xff342000, 0x1000), at
 0x117ac
  [8] _exithandle(0xfecf4540, 0xfeb416c0, 0xfecf3580, 0x34930, 0x0,
 0xffbffb60), at 0xfec418dc
  [9] exit(0x0, 0xffbffbfc, 0xffbffc04, 0x2222c, 0xfeb416c0,
 0xfeb41700), at 0xfec301f0
(dbx) quit
sol10-116200#
sol10-116200# uname -a
SunOS sol10-116200 5.10 Generic_127111-01 sun4u sparc
 SUNW,Sun-Fire-V245
sol10-116200#
sol10-116200# /usr/sfw/bin/g++ -v
Reading specs from /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/specs
Configured with:
 /gates/sfw10/builds/sfw10-gate/usr/src/cmd/gcc/gcc-3.4.3/configure
--prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as
 --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++
 --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
sol10-116200#
 
The program will work perfectly if I moved the line "LoggerPtr
 logger(Logger::getLogger("MyApp"));" inside main. 
 
This model was working well with previous  version log4cxx-r603007. I am
planning to upgrade the log4cxx to release 0.10.
 
We have defined "LoggerPtr logger(Logger::getLogger("MyApp"));" outside
of main in out application and its difficult to  change our application
at this point. 
Is there any way for making it work on Solaris without modifying the
 example program? Let me know if you need more information.
 
I appreciate your help.
 

 

Regards,

Unnikrishnan

Reply via email to