You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Andreas Volz <li...@brachttal.net> on 2011/01/18 00:15:46 UTC

Crash at exit

Hello,

I just started with using log4cxx. It's a nice logging library and I
like using it. But for some reason I get a crash at exiting my program.
I run it in the debugger and here is the result:

Program received signal SIGSEGV, Segmentation fault.
0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized out>)
    at /usr/include/log4cxx/helpers/objectptr.h:100
100	                  p->releaseRef();
(gdb) bt
#0  0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized out>)
    at /usr/include/log4cxx/helpers/objectptr.h:100
#1  0x0093d2cf in std::_Rb_tree<std::string, std::pair<std::string const, std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>, std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > >, std::_Select1st<std::pair<std::string const, std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>, std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > > >, std::less<std::string>, std::allocator<std::pair<std::string const, std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>, std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > > > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, std::vector<log4cxx::helpers::ObjectPtrT<log4cxx::Logger>, std::allocator<log4cxx::helpers::ObjectPtrT<log4cxx::Logger> > > > >*) () from /usr/lib/liblog4cxx.so.10
#2  0x0093b4a4 in log4cxx::Hierarchy::~Hierarchy() () from /usr/lib/liblog4cxx.so.10
#3  0x00961b75 in log4cxx::helpers::ObjectImpl::releaseRef() const () from /usr/lib/liblog4cxx.so.10
#4  0x00939972 in log4cxx::Hierarchy::releaseRef() const () from /usr/lib/liblog4cxx.so.10
#5  0x009561f7 in log4cxx::spi::DefaultRepositorySelector::~DefaultRepositorySelector() ()
   from /usr/lib/liblog4cxx.so.10
#6  0x00961b75 in log4cxx::helpers::ObjectImpl::releaseRef() const () from /usr/lib/liblog4cxx.so.10
#7  0x0091d832 in log4cxx::spi::DefaultRepositorySelector::releaseRef() const () from /usr/lib/liblog4cxx.so.10
#8  0x00956099 in log4cxx::helpers::ObjectPtrT<log4cxx::spi::RepositorySelector>::~ObjectPtrT() ()
   from /usr/lib/liblog4cxx.so.10
#9  0x00702588 in __cxa_finalize (d=0xa0338c) at cxa_finalize.c:56
#10 0x009001e4 in ?? () from /usr/lib/liblog4cxx.so.10
#11 0x009adcd0 in _fini () from /usr/lib/liblog4cxx.so.10
#12 0x0011e216 in _dl_fini () at dl-fini.c:248
#13 0x007021bf in __run_exit_handlers (status=0, listp=0x829324, run_list_atexit=true) at exit.c:78
#14 0x0070222f in *__GI_exit (status=0) at exit.c:100
#15 0x006e9bde in __libc_start_main (main=0x806124d <main>, argc=1, ubp_av=0xbfffee54, 
    init=0x80636a0 <__libc_csu_init>, fini=0x8063690 <__libc_csu_fini>, rtld_fini=0x11e030 <_dl_fini>, 
---Type <return> to continue, or q <return> to quit---
    stack_end=0xbfffee4c) at libc-start.c:258
#16 0x080534f1 in _start ()

Maybe it's a problem how I use log4cxx. I defined a stupid wrapper class for my project:

http://codepad.org/EWDVx8mE

This helps me to cut down dependencies (e.g. for a win32 build where no development happens).

Then I use the Logger object like this:

in the application:

// all needed includes and namespaces direct
...
PropertyConfigurator::configure (searchDataDir () + "/logging.prop");

and then the wrapper in the library (only cpp files!)

static Logger logger ("stateval.StateMachineThread");

void MyClass::myFucntion ()
{
  LOG4CXX_TRACE (logger, "a trace");
}

The logging works, but it crashes at exit...

I won't like to put Logger as member in the Header files to cut down
dependencies. And it needs to be static for sure...

So have you any ideas what I made wrong here?

Have you any experiences how you organise your logger variables
in your source code?

regards
	Andreas

Re: Crash at exit

Posted by ca...@encopim.com.
When I said he called a 'aprterminate ()' wanted to _not_ called  
'aprterminate ()', which had commented on log4cxx

thanks

Quoting Thorsten Schöning <ts...@am-soft.de>:

> Guten Tag carlos_jimenez@encopim.com,
> am Dienstag, 18. Januar 2011 um 13:47 schrieben Sie:
>
>> Anyone have any idea?
>
> Don't call apr_terminate at all, uncomment it in Log4cxx.
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning
> AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
>
> Telefon: Potsdam: 0331-743881-0
> E-Mail:  tschoening@am-soft.de
> Web:     http://www.am-soft.de
>
> AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
> Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow
>
>



-- 
Carlos Jiménez

ENCOPIM S.L.
C/. del Parc 5 (nau 13), P.I. Els Pinetons
E-08291 RIPOLLET (Barcelona)
Tel: (+34) 935 94 23 47
Fax: (+34) 935 94 64 15

==========================================================
La información contenida en la presente transmisión es confidencial y su
uso únicamente está permitido a su(s) destinatario(s). Si Ud. no es la
persona destinataria de la presente transmisión, rogamos nos lo
comunique de manera inmediata por teléfono (+34 935 942 347) y destruya
cualquier copia de la misma (tanto digitales como en papel).

The information contained in this transmission is confidential and is
intended only for the use of the addressee(s). If you are not the
designated recipient of this transmission, please advise us immediately
by telephone (+34 935 942 347) and destroy any copies (digital and
paper).
==========================================================

Re: Crash at exit

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag carlos_jimenez@encopim.com,
am Dienstag, 18. Januar 2011 um 13:47 schrieben Sie:

> Anyone have any idea?

Don't call apr_terminate at all, uncomment it in Log4cxx.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
 
Telefon: Potsdam: 0331-743881-0
E-Mail:  tschoening@am-soft.de
Web:     http://www.am-soft.de

AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow


Re: Crash at exit

Posted by ca...@encopim.com.
I had a similar problem, after exit(0):

*** glibc detected *** ./main: double free or corruption (out): 0x08f10b20 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7356624]
/lib/i686/cmov/libc.so.6(cfree+0x96)[0xb7358826]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb75472e1]
/usr/local/lib/liblog4cxx.so.10(_ZN7log4cxx6LoggerD0Ev+0xfd)[0xb77c48dd]
/usr/local/lib/liblog4cxx.so.10(_ZNK7log4cxx7helpers10ObjectImpl10releaseRefEv+0x37)[0xb77d8a07]
/usr/local/lib/liblog4cxx.so.10(_ZNK7log4cxx6Logger10releaseRefEv+0x22)[0xb77c1b62]
./main(_ZN7log4cxx7helpers10ObjectPtrTINS_6LoggerEED1Ev+0x24)[0x804ea84]
/usr/local/lib/liblog4cxx.so.10(_ZNSt8_Rb_treeISsSt4pairIKSsN7log4cxx7helpers10ObjectPtrTINS2_6LoggerEEEESt10_Select1stIS7_ESt4lessISsESaIS7_EE8_M_eraseEPSt13_Rb_tree_nodeIS7_E+0x32)[0xb77ad062]
/usr/local/lib/liblog4cxx.so.10(_ZN7log4cxx9HierarchyD0Ev+0x40)[0xb77aaee0]
/usr/local/lib/liblog4cxx.so.10(_ZNK7log4cxx7helpers10ObjectImpl10releaseRefEv+0x37)[0xb77d8a07]
/usr/local/lib/liblog4cxx.so.10(_ZNK7log4cxx9Hierarchy10releaseRefEv+0x22)[0xb77a9052]
/usr/local/lib/liblog4cxx.so.10(_ZN7log4cxx3spi25DefaultRepositorySelectorD0Ev+0x53)[0xb77cbaf3]
/usr/local/lib/liblog4cxx.so.10(_ZNK7log4cxx7helpers10ObjectImpl10releaseRefEv+0x37)[0xb77d8a07]
/usr/local/lib/liblog4cxx.so.10(_ZNK7log4cxx3spi25DefaultRepositorySelector10releaseRefEv+0x22)[0xb7788a52]
/usr/local/lib/liblog4cxx.so.10[0xb77cab6f]
/lib/i686/cmov/libc.so.6(exit+0x89)[0xb7316ab9]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xed)[0xb72fe45d]
./main[0x804bc91]
======= Memory map: ========
-----------------------------------------------------------------------


I tried different things, I call 'apr_terminate ()' from log4cxx, call  
'LogManager:: shutdown ()' just before the exit (0) and Apply this:  
http://old.nabble.com/Fix-possible  
-crash-on-exit-when-using-static-Loggers-td19473591.html

Anyone have any idea?

thanks in advance


Quoting Oscar Pernas <os...@pernas.es>:

> I resolved it not calling the apr_terminate method. Log4cxx call it when the
> destructor is called.
>
> 2011/1/18 Fabian Jacquet <fa...@gmail.com>
>
>> I have the same problem if I use log4cxx.AsyncAppender.
>> I fixed the problem by calling log4cxx::LogManager::shutdown(); before the
>> end of the process.
>> It's not very clean but it works.
>>
>>
>> On Tue, Jan 18, 2011 at 09:40, Oscar Pernas <os...@pernas.es> wrote:
>>
>>> I had the same problem. In my case, It was caused because log4cxx uses APR
>>> libraries, and in my project I was using too. Are you using APR in your
>>> project? are you making a apr_terminate in your code?
>>>
>>> Regards
>>>
>>> 2011/1/18 Thorsten Schöning <ts...@am-soft.de>
>>>
>>> Guten Tag Andreas Volz,
>>>> am Dienstag, 18. Januar 2011 um 00:15 schrieben Sie:
>>>>
>>>> > Program received signal SIGSEGV, Segmentation fault.
>>>> > 0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized
>>>> out>)
>>>> >     at /usr/include/log4cxx/helpers/objectptr.h:100
>>>> > 100                       p->releaseRef();
>>>>
>>>> Sounds that the following may be the reason:
>>>>
>>>>
>>>> http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200901.mbox/%3C4975157F.8070001@purplescarab.com%3E
>>>> http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg03188.html
>>>>
>>>> Mit freundlichen Grüßen,
>>>>
>>>> Thorsten Schöning
>>>>
>>>> --
>>>> Thorsten Schöning
>>>> AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
>>>>
>>>> Telefon: Potsdam: 0331-743881-0
>>>> E-Mail:  tschoening@am-soft.de
>>>> Web:     http://www.am-soft.de
>>>>
>>>> AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
>>>> Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow
>>>>
>>>>
>>>
>>>
>>> --
>>> Óscar Pernas Plaza.
>>>
>>
>>
>
>
> --
> Óscar Pernas Plaza.
>



-- 
Carlos Jiménez

ENCOPIM S.L.
C/. del Parc 5 (nau 13), P.I. Els Pinetons
E-08291 RIPOLLET (Barcelona)
Tel: (+34) 935 94 23 47
Fax: (+34) 935 94 64 15

==========================================================
La información contenida en la presente transmisión es confidencial y su
uso únicamente está permitido a su(s) destinatario(s). Si Ud. no es la
persona destinataria de la presente transmisión, rogamos nos lo
comunique de manera inmediata por teléfono (+34 935 942 347) y destruya
cualquier copia de la misma (tanto digitales como en papel).

The information contained in this transmission is confidential and is
intended only for the use of the addressee(s). If you are not the
designated recipient of this transmission, please advise us immediately
by telephone (+34 935 942 347) and destroy any copies (digital and
paper).
==========================================================

Re: Crash at exit

Posted by Oscar Pernas <os...@pernas.es>.
I resolved it not calling the apr_terminate method. Log4cxx call it when the
destructor is called.

2011/1/18 Fabian Jacquet <fa...@gmail.com>

> I have the same problem if I use log4cxx.AsyncAppender.
> I fixed the problem by calling log4cxx::LogManager::shutdown(); before the
> end of the process.
> It's not very clean but it works.
>
>
> On Tue, Jan 18, 2011 at 09:40, Oscar Pernas <os...@pernas.es> wrote:
>
>> I had the same problem. In my case, It was caused because log4cxx uses APR
>> libraries, and in my project I was using too. Are you using APR in your
>> project? are you making a apr_terminate in your code?
>>
>> Regards
>>
>> 2011/1/18 Thorsten Schöning <ts...@am-soft.de>
>>
>> Guten Tag Andreas Volz,
>>> am Dienstag, 18. Januar 2011 um 00:15 schrieben Sie:
>>>
>>> > Program received signal SIGSEGV, Segmentation fault.
>>> > 0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized
>>> out>)
>>> >     at /usr/include/log4cxx/helpers/objectptr.h:100
>>> > 100                       p->releaseRef();
>>>
>>> Sounds that the following may be the reason:
>>>
>>>
>>> http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200901.mbox/%3C4975157F.8070001@purplescarab.com%3E
>>> http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg03188.html
>>>
>>> Mit freundlichen Grüßen,
>>>
>>> Thorsten Schöning
>>>
>>> --
>>> Thorsten Schöning
>>> AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
>>>
>>> Telefon: Potsdam: 0331-743881-0
>>> E-Mail:  tschoening@am-soft.de
>>> Web:     http://www.am-soft.de
>>>
>>> AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
>>> Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow
>>>
>>>
>>
>>
>> --
>> Óscar Pernas Plaza.
>>
>
>


-- 
Óscar Pernas Plaza.

Re: Crash at exit

Posted by Fabian Jacquet <fa...@gmail.com>.
I have the same problem if I use log4cxx.AsyncAppender.
I fixed the problem by calling log4cxx::LogManager::shutdown(); before the
end of the process.
It's not very clean but it works.

On Tue, Jan 18, 2011 at 09:40, Oscar Pernas <os...@pernas.es> wrote:

> I had the same problem. In my case, It was caused because log4cxx uses APR
> libraries, and in my project I was using too. Are you using APR in your
> project? are you making a apr_terminate in your code?
>
> Regards
>
> 2011/1/18 Thorsten Schöning <ts...@am-soft.de>
>
> Guten Tag Andreas Volz,
>> am Dienstag, 18. Januar 2011 um 00:15 schrieben Sie:
>>
>> > Program received signal SIGSEGV, Segmentation fault.
>> > 0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized
>> out>)
>> >     at /usr/include/log4cxx/helpers/objectptr.h:100
>> > 100                       p->releaseRef();
>>
>> Sounds that the following may be the reason:
>>
>>
>> http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200901.mbox/%3C4975157F.8070001@purplescarab.com%3E
>> http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg03188.html
>>
>> Mit freundlichen Grüßen,
>>
>> Thorsten Schöning
>>
>> --
>> Thorsten Schöning
>> AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
>>
>> Telefon: Potsdam: 0331-743881-0
>> E-Mail:  tschoening@am-soft.de
>> Web:     http://www.am-soft.de
>>
>> AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
>> Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow
>>
>>
>
>
> --
> Óscar Pernas Plaza.
>

Re: Crash at exit

Posted by Oscar Pernas <os...@pernas.es>.
I had the same problem. In my case, It was caused because log4cxx uses APR
libraries, and in my project I was using too. Are you using APR in your
project? are you making a apr_terminate in your code?

Regards

2011/1/18 Thorsten Schöning <ts...@am-soft.de>

> Guten Tag Andreas Volz,
> am Dienstag, 18. Januar 2011 um 00:15 schrieben Sie:
>
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized
> out>)
> >     at /usr/include/log4cxx/helpers/objectptr.h:100
> > 100                       p->releaseRef();
>
> Sounds that the following may be the reason:
>
>
> http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200901.mbox/%3C4975157F.8070001@purplescarab.com%3E
> http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg03188.html
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning
> AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
>
> Telefon: Potsdam: 0331-743881-0
> E-Mail:  tschoening@am-soft.de
> Web:     http://www.am-soft.de
>
> AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
> Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow
>
>


-- 
Óscar Pernas Plaza.

Re: Crash at exit

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Andreas Volz,
am Dienstag, 18. Januar 2011 um 00:15 schrieben Sie:

> Program received signal SIGSEGV, Segmentation fault.
> 0x001b2614 in ~ObjectPtrT (this=0x80ef7b8, __in_chrg=<value optimized out>)
>     at /usr/include/log4cxx/helpers/objectptr.h:100
> 100                       p->releaseRef();

Sounds that the following may be the reason:

http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200901.mbox/%3C4975157F.8070001@purplescarab.com%3E
http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg03188.html

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
 
Telefon: Potsdam: 0331-743881-0
E-Mail:  tschoening@am-soft.de
Web:     http://www.am-soft.de

AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow