Menu

#330 crash during threadCleanup

v1.1.2
open
5
2016-06-23
2016-04-26
No

Hello,

I am using log4cplus with my application in a following way:

  • OS: RHEL: 7.2 x64
  • compiler gcc-4.8.5
  • log4cplus is build as : make -C log4cplus
  • my app is build with -std=c++11
  • I have logwrapper around log4cplus lib that proxies some calls there (it is needed to unify logging API for several projects). so the loggin scheme is like:
    app--log()-->logwrapper->log4cplus
  • my app is linked to logwrapper, BUT at the same time it uses some direct calls to log4cplus (NDC and LOG4CPLUS_[DEBUG|INFO] macros)
  • my app initializes log4cplus during startup and use it like singleton
  • my app uses shared libs that are loaded in runtime and these plugins use logwrapper as well

The issue appears during app shutdown and produces following backtrace:

#0  0x00007fc9c530856b in malloc_consolidate () from /lib64/libc.so.6
#1  0x00007fc9c53090e7 in _int_free () from /lib64/libc.so.6
#2  0x00007fc9c5ea5189 in _M_dispose (__a=..., this=<optimized out>) at /usr/include/c++/4.8.2/bits/basic_string.h:249
#3  ~basic_string (this=0x1231c50, __in_chrg=<optimized out>) at /usr/include/c++/4.8.2/bits/basic_string.h:539
#4  ~basic_stringbuf (this=0x1231c08, __in_chrg=<optimized out>) at /usr/include/c++/4.8.2/sstream:64
#5  ~basic_ostringstream (this=0x1231c00, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /usr/include/c++/4.8.2/sstream:453
#6  log4cplus::internal::per_thread_data::~per_thread_data (this=0x1231c00, __in_chrg=<optimized out>) at global-init.cxx:255
#7  0x00007fc9c5ea52e4 in log4cplus::threadCleanup () at global-init.cxx:391
#8  0x00007fc9c5ea530c in (anonymous namespace)::_static_log4cplus_initializer::~_static_log4cplus_initializer (this=<optimized out>, __in_chrg=<optimized out>) at global-init.cxx:553
#9  0x00007fc9c52c51ba in __cxa_finalize () from /lib64/libc.so.6
#10 0x00007fc9c5e8e063 in __do_global_dtors_aux () from /lib64/liblog4cplus-1.1.so.9
#11 0x00007ffecb9db980 in ?? ()
#12 0x00007fc9cc0a2b5a in _dl_fini () from /lib64/ld-linux-x86-64.so.2

NOTE: in case my app doesn't use dynamic plugins loading or all calls to log4cplus is wrapped (I mean there is no direct calls app->log4cplus, but only app->wrapper->log4cplus) the crash disappears.

Could you please point me to the reason of such behavior?

Discussion

  • Václav Haisman

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

    Diff:

    --- old
    +++ new
    @@ -13,6 +13,7 @@
    
     The issue appears during app shutdown and produces following backtrace:
    
    +~~~
     #0  0x00007fc9c530856b in malloc_consolidate () from /lib64/libc.so.6
     #1  0x00007fc9c53090e7 in _int_free () from /lib64/libc.so.6
     #2  0x00007fc9c5ea5189 in _M_dispose (__a=..., this=<optimized out>) at /usr/include/c++/4.8.2/bits/basic_string.h:249
    @@ -26,7 +27,7 @@
     #10 0x00007fc9c5e8e063 in __do_global_dtors_aux () from /lib64/liblog4cplus-1.1.so.9
     #11 0x00007ffecb9db980 in ?? ()
     #12 0x00007fc9cc0a2b5a in _dl_fini () from /lib64/ld-linux-x86-64.so.2
    -
    +~~~
    
     NOTE: in case my app doesn't use dynamic plugins loading or all calls to log4cplus is wrapped (I mean there is no direct calls app->log4cplus, but only app->wrapper->log4cplus) the crash disappears.
    
     
  • Václav Haisman

    Václav Haisman - 2016-04-26

    The only thing I see imediately as odd is that your call stack contains references to /lib64/liblog4cplus-1.1.so.9. Is it the actual log4cplus that you have compiled or is it by a chance OS installed one?

     
    • Maxim Kondratenko

      We build this lib. Our RHEL OS doesn't have this rpm from the box.

      Could you please tell me what is wrong with this lib version?

       
      • Maxim Kondratenko

        btw, is this a proper way to build log4cplus for my app?
        make -C log4cplus

        Should I consider using multithreaded and c++11 version of log4cplus?

         
        • Václav Haisman

          Václav Haisman - 2016-04-26

          You definitely have to keep the same settings for the library and for your application, so either both C++11 or both not C++11.

           
          • Maxim Kondratenko

            I have compiled log4cplus and my wrapper with -std=c++11 flag - result is the same

             
      • Václav Haisman

        Václav Haisman - 2016-04-26

        I cannot tell what is going on. Can you try and run some os the tests that are built when the library is built? Do they crash? I think the easies it the thread_test test.

         
        • Maxim Kondratenko

          The tests are passed successfully.
          I guess there is a problem with static global variables and using htem from shared libraries, because once I have changed my plugins to be statically compiled into my app - the issue has gone.

           
  • Václav Haisman

    Václav Haisman - 2016-04-26
    • labels: --> crash, linux, rhel, v1.1.2
    • assigned_to: Václav Haisman
     
  • Václav Haisman

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

    Diff:

    --- old
    +++ new
    @@ -1,15 +1,16 @@
     Hello,
    
     I am using log4cplus with my application in a following way:
    -- OS: RHEL: 7.2 x64
    -- compiler gcc-4.8.5
    -- log4cplus is build as : make -C log4cplus
    -- my app is build with -std=c++11
    -- I have logwrapper around log4cplus lib that proxies some calls there (it is needed to unify  logging API for several projects). so the loggin scheme is like:
    -- app--log()-->logwrapper->log4cplus
    -- my app is linked to logwrapper, BUT at the same time it uses some direct calls to log4cplus (NDC and LOG4CPLUS_[DEBUG|INFO] macros)
    -- my app initializes log4cplus during startup and use it like singleton 
    -- my app uses shared libs that are loaded in runtime and these plugins use logwrapper as well
    +
    +* OS: RHEL: 7.2 x64
    +* compiler gcc-4.8.5
    +* log4cplus is build as : `make -C log4cplus`
    +* my app is build with `-std=c++11`
    +* I have logwrapper around log4cplus lib that proxies some calls there (it is needed to unify  logging API for several projects). so the loggin scheme is like:
    +    app--log()-->logwrapper->log4cplus
    +* my app is linked to logwrapper, BUT at the same time it uses some direct calls to log4cplus (`NDC` and `LOG4CPLUS_[DEBUG|INFO]` macros)
    +* my app initializes log4cplus during startup and use it like singleton 
    +* my app uses shared libs that are loaded in runtime and these plugins use logwrapper as well
    
     The issue appears during app shutdown and produces following backtrace:
    
     
  • Maxim Kondratenko

    For the time being the issue is not reproducible - I have changed my app to use static libs.

     

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.