Menu

#326 Crash on exit or return in Hierarchy::initializeLoggerList

v1.1.3
open
5
2016-03-22
2016-02-04
No

Hello there,
I am working with v1.1.3 rc3 on Linux, compiled with -m32, dynamically linked to my application.

The attached file traces.txt has two gdb traces, one when my application uses exit() inside its main(), at the very end of it. And one when using return() instead of exit().

In both cases my application will crash, further information I get on standard out is:

terminate called after throwing an instance of 'std::runtime_error'
  what():  ../include/log4cplus/thread/impl/syncprims-pthreads.h:122Mutex::lock

Using exit():

#0  0xffffe410 in __kernel_vsyscall ()
(gdb) where
#0  0xffffe410 in __kernel_vsyscall ()
#1  0x00984b10 in raise () from /lib/libc.so.6
#2  0x00986421 in abort () from /lib/libc.so.6
#3  0x00bc3be0 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#4  0x00bc15b5 in ?? () from /usr/lib/libstdc++.so.6
#5  0x00bc15f2 in std::terminate() () from /usr/lib/libstdc++.so.6
#6  0x00bc16ab in __cxa_rethrow () from /usr/lib/libstdc++.so.6
#7  0xf7ef1dbd in std::vector<log4cplus::Logger, std::allocator<log4cplus::Logger> >::_M_insert_aux (this=0xfff2b214, __position=Cannot access memory at address 0x0
)
    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:296
#8  0xf7ef00de in push_back (this=0x871de54, list=std::vector of length 0, capacity 0)
    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:610
#9  log4cplus::Hierarchy::initializeLoggerList (this=0x871de54, list=std::vector of length 0, capacity 0) at hierarchy.cxx:305
#10 0xf7ef04ce in log4cplus::Hierarchy::getCurrentLoggers (this=0x871de54) at hierarchy.cxx:178
#11 0xf7ef02b9 in log4cplus::Hierarchy::shutdown (this=0x871de54) at hierarchy.cxx:235
#12 0xf7ef07a0 in log4cplus::Hierarchy::~Hierarchy (this=0x871de54, __in_chrg=<value optimized out>) at hierarchy.cxx:80
#13 0xf7eed3c1 in ~DefaultContext () at global-init.cxx:59
#14 ~destroy_default_context () at global-init.cxx:90
#15 __tcf_1 () at global-init.cxx:94
#16 0x00987e99 in __cxa_finalize () from /lib/libc.so.6
#17 0xf7ed39b4 in __do_global_dtors_aux () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
#18 0xf7f1799c in _fini () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
#19 0x0094ba86 in _dl_fini () from /lib/ld-linux.so.2
#20 0x00987be9 in exit () from /lib/libc.so.6
#21 0x08050e99 in main (argc=3, argv=0xfff2b734) at myapp.cpp:42

Using return():

Program terminated with signal 11, Segmentation fault.
#0  lock (this=0x4267d728) at ../include/log4cplus/thread/impl/syncprims-pthreads.h:120
120     ../include/log4cplus/thread/impl/syncprims-pthreads.h: No such file or directory.
        in ../include/log4cplus/thread/impl/syncprims-pthreads.h
(gdb) where
#0  lock (this=0x4267d728) at ../include/log4cplus/thread/impl/syncprims-pthreads.h:120
#1  log4cplus::thread::Mutex::lock (this=0x4267d728) at ../include/log4cplus/thread/syncprims-pub-impl.h:83
#2  0xf7e65ed8 in SyncGuard (this=0x4267d724) at ../include/log4cplus/thread/syncprims.h:248
#3  log4cplus::helpers::SharedObject::addReference (this=0x4267d724) at pointer.cxx:70
#4  0xf7e56a92 in log4cplus::Logger::Logger (this=0x81ee300, rhs=...) at logger.cxx:118
#5  0xf7e50c7a in construct (this=0xff84c8b4, __position=Cannot access memory at address 0x0
)
    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:104
#6  std::vector<log4cplus::Logger, std::allocator<log4cplus::Logger> >::_M_insert_aux (this=0xff84c8b4, __position=Cannot access memory at address 0x0
)
    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:284
#7  0xf7e4f0de in push_back (this=0x81ede54, list=std::vector of length 0, capacity 0)
    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:610
#8  log4cplus::Hierarchy::initializeLoggerList (this=0x81ede54, list=std::vector of length 0, capacity 0) at hierarchy.cxx:305
#9  0xf7e4f4ce in log4cplus::Hierarchy::getCurrentLoggers (this=0x81ede54) at hierarchy.cxx:178
#10 0xf7e4f2b9 in log4cplus::Hierarchy::shutdown (this=0x81ede54) at hierarchy.cxx:235
#11 0xf7e4f7a0 in log4cplus::Hierarchy::~Hierarchy (this=0x81ede54, __in_chrg=<value optimized out>) at hierarchy.cxx:80
#12 0xf7e4c3c1 in ~DefaultContext () at global-init.cxx:59
#13 ~destroy_default_context () at global-init.cxx:90
#14 __tcf_1 () at global-init.cxx:94
#15 0x00987e99 in __cxa_finalize () from /lib/libc.so.6
#16 0xf7e329b4 in __do_global_dtors_aux () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
#17 0xf7e7699c in _fini () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
#18 0x0094ba86 in _dl_fini () from /lib/ld-linux.so.2
#19 0x00987be9 in exit () from /lib/libc.so.6
#20 0x00971ee4 in __libc_start_main () from /lib/libc.so.6
#21 0x0804bb11 in _start ()

Thanks in advance for any help,
Stephan

1 Attachments

Discussion

  • Václav Haisman

    Václav Haisman - 2016-02-04
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,12 +1,83 @@
     Hello there,
     I am working with v1.1.3 rc3 on Linux, compiled with -m32, dynamically linked to my application.
    
    -The attached file traces.txt has two gdb traces, one when my application uses exit() inside its main(), at the very end of it.  And one when using return() instead of exit().
    +The attached file traces.txt has two gdb traces, one when my application uses `exit()` inside its `main()`, at the very end of it.  And one when using `return()` instead of `exit()`.
    
     In both cases my application will crash, further information I get on standard out is:
    
    +~~~~
     terminate called after throwing an instance of 'std::runtime_error'
       what():  ../include/log4cplus/thread/impl/syncprims-pthreads.h:122Mutex::lock
    -  
    +~~~~
    +
    +Using `exit()`:
    +
    +~~~~
    +#0  0xffffe410 in __kernel_vsyscall ()
    +(gdb) where
    +#0  0xffffe410 in __kernel_vsyscall ()
    +#1  0x00984b10 in raise () from /lib/libc.so.6
    +#2  0x00986421 in abort () from /lib/libc.so.6
    +#3  0x00bc3be0 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
    +#4  0x00bc15b5 in ?? () from /usr/lib/libstdc++.so.6
    +#5  0x00bc15f2 in std::terminate() () from /usr/lib/libstdc++.so.6
    +#6  0x00bc16ab in __cxa_rethrow () from /usr/lib/libstdc++.so.6
    +#7  0xf7ef1dbd in std::vector<log4cplus::Logger, std::allocator<log4cplus::Logger> >::_M_insert_aux (this=0xfff2b214, __position=Cannot access memory at address 0x0
    +)
    +    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:296
    +#8  0xf7ef00de in push_back (this=0x871de54, list=std::vector of length 0, capacity 0)
    +    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:610
    +#9  log4cplus::Hierarchy::initializeLoggerList (this=0x871de54, list=std::vector of length 0, capacity 0) at hierarchy.cxx:305
    +#10 0xf7ef04ce in log4cplus::Hierarchy::getCurrentLoggers (this=0x871de54) at hierarchy.cxx:178
    +#11 0xf7ef02b9 in log4cplus::Hierarchy::shutdown (this=0x871de54) at hierarchy.cxx:235
    +#12 0xf7ef07a0 in log4cplus::Hierarchy::~Hierarchy (this=0x871de54, __in_chrg=<value optimized out>) at hierarchy.cxx:80
    +#13 0xf7eed3c1 in ~DefaultContext () at global-init.cxx:59
    +#14 ~destroy_default_context () at global-init.cxx:90
    +#15 __tcf_1 () at global-init.cxx:94
    +#16 0x00987e99 in __cxa_finalize () from /lib/libc.so.6
    +#17 0xf7ed39b4 in __do_global_dtors_aux () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
    +#18 0xf7f1799c in _fini () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
    +#19 0x0094ba86 in _dl_fini () from /lib/ld-linux.so.2
    +#20 0x00987be9 in exit () from /lib/libc.so.6
    +#21 0x08050e99 in main (argc=3, argv=0xfff2b734) at myapp.cpp:42
    +~~~~
    +
    +Using `return()`:
    +
    +~~~~
    +Program terminated with signal 11, Segmentation fault.
    +#0  lock (this=0x4267d728) at ../include/log4cplus/thread/impl/syncprims-pthreads.h:120
    +120     ../include/log4cplus/thread/impl/syncprims-pthreads.h: No such file or directory.
    +        in ../include/log4cplus/thread/impl/syncprims-pthreads.h
    +(gdb) where
    +#0  lock (this=0x4267d728) at ../include/log4cplus/thread/impl/syncprims-pthreads.h:120
    +#1  log4cplus::thread::Mutex::lock (this=0x4267d728) at ../include/log4cplus/thread/syncprims-pub-impl.h:83
    +#2  0xf7e65ed8 in SyncGuard (this=0x4267d724) at ../include/log4cplus/thread/syncprims.h:248
    +#3  log4cplus::helpers::SharedObject::addReference (this=0x4267d724) at pointer.cxx:70
    +#4  0xf7e56a92 in log4cplus::Logger::Logger (this=0x81ee300, rhs=...) at logger.cxx:118
    +#5  0xf7e50c7a in construct (this=0xff84c8b4, __position=Cannot access memory at address 0x0
    +)
    +    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:104
    +#6  std::vector<log4cplus::Logger, std::allocator<log4cplus::Logger> >::_M_insert_aux (this=0xff84c8b4, __position=Cannot access memory at address 0x0
    +)
    +    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:284
    +#7  0xf7e4f0de in push_back (this=0x81ede54, list=std::vector of length 0, capacity 0)
    +    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:610
    +#8  log4cplus::Hierarchy::initializeLoggerList (this=0x81ede54, list=std::vector of length 0, capacity 0) at hierarchy.cxx:305
    +#9  0xf7e4f4ce in log4cplus::Hierarchy::getCurrentLoggers (this=0x81ede54) at hierarchy.cxx:178
    +#10 0xf7e4f2b9 in log4cplus::Hierarchy::shutdown (this=0x81ede54) at hierarchy.cxx:235
    +#11 0xf7e4f7a0 in log4cplus::Hierarchy::~Hierarchy (this=0x81ede54, __in_chrg=<value optimized out>) at hierarchy.cxx:80
    +#12 0xf7e4c3c1 in ~DefaultContext () at global-init.cxx:59
    +#13 ~destroy_default_context () at global-init.cxx:90
    +#14 __tcf_1 () at global-init.cxx:94
    +#15 0x00987e99 in __cxa_finalize () from /lib/libc.so.6
    +#16 0xf7e329b4 in __do_global_dtors_aux () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
    +#17 0xf7e7699c in _fini () from /opt/log4cplus/lib/liblog4cplus-1.1.so.9
    +#18 0x0094ba86 in _dl_fini () from /lib/ld-linux.so.2
    +#19 0x00987be9 in exit () from /lib/libc.so.6
    +#20 0x00971ee4 in __libc_start_main () from /lib/libc.so.6
    +#21 0x0804bb11 in _start ()
    +~~~~
    +
     Thanks in advance for any help,
     Stephan
    
     
  • Václav Haisman

    Václav Haisman - 2016-02-04

    This looks odd. First the Mutex message:

    terminate called after throwing an instance of 'std::runtime_error'
      what():  ../include/log4cplus/thread/impl/syncprims-pthreads.h:122Mutex::lock
    

    This looks like it is throwing on pthread_mutex_lock (&mtx) failure. It should not happen. Can you check your application, that you are linking with all the appropriate switching, including -pthread or its equivalent replacement?

     
  • Stephan Bielmann

    Well, yes and no. I do not explicitely set -pthread when compiling, however ldd tells me that it has been linked. I do get the very same results, whether I am using -pthread or not.

    However there is a difference, the Mutext message is only printed out when I use TRACE log
    level. In INFO log level it does not appear. I sure do log more in DEBUG and TRACE than in
    INFO inside my application.

     
  • Václav Haisman

    Václav Haisman - 2016-02-05
    • assigned_to: Václav Haisman
     
  • Václav Haisman

    Václav Haisman - 2016-02-05

    I cannot think of a reason why this would be failing. Are the tests that are compiled together with the library failing as well?

     
  • Stephan Bielmann

    No test is failing, whether with make check, make checkinstall, nor when executed manually.

     
  • Václav Haisman

    Václav Haisman - 2016-03-22
    • labels: --> crash, linux
     
  • Václav Haisman

    Václav Haisman - 2016-03-22
    • labels: crash, linux --> crash, linux, v1.1.3
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.