Menu

#51 0.3.4b Error - Appender::_addAppender()

open
nobody
appenders (19)
5
2002-12-09
2002-12-09
ms
No

I have been using 0.2.7 for a few months without
problem. I recently discovered a problem regarding the
Log4cppCleanup class, but noticed that this class has
been removed in the latest (non-stable) release. I
downloaded 0.3.4b which compiled fine. When I try and
use my existing code in VC++ .NET (i just called
Category::getInstance( "name" ) infact), I get an
exception Appender::_addAppender.

An attempt to create a ScopedLock object fails,
seemingly because of null pointers.

void Appender::_addAppender(Appender* appender) {

//REQUIRE(_allAppenders.find(appender->getName()) ==
_getAllAppenders().end())
threading::ScopedLock lock(_appenderMapMutex);
_getAllAppenders()[appender->getName()] = appender;
}

Has anyone else experienced this and are there any
solutions?

When is the next stable release scheduled for?

Discussion

  • Marco Villani

    Marco Villani - 2002-12-10

    Logged In: YES
    user_id=658521

    Sorry for my English.

    Your problem (Error [ 650940 ] 0.3.4b Error -
    Appender::_addAppender() )
    could be similar to this problem:
    [ 645270 ] May be there is a problem in PThreads.hh

    See:
    https://sourceforge.net/tracker/index.php?
    func=detail&aid=645270&group_id=15190&atid=11519
    0
    and then:
    http://cvs.sourceforge.net/cgi-
    bin/viewcvs.cgi/log4cpp/log4cpp/include/log4cpp/thre
    ading/PThreads.hh

    CVS log for
    log4cpp/log4cpp/include/log4cpp/threading/PThreads.
    hh

    Revision 1.4 / (view) - annotate - [select for diffs] , Thu
    Nov 28 18:15:29 2002 UTC (11 days, 20 hours ago) by
    bastiaan
    Branch: MAIN
    CVS Tags: HEAD
    Changes since 1.3: +6 -6 lines
    Diff to previous 1.3
    Fix Mutex copy bug (#645270) as suggested by Robert
    Ballarin.

    Best regards.

     
  • Nobody/Anonymous

    Logged In: NO

    Hello,

    i experienced the same problem, some other bug reports
    seem to go in same direction...

    Well the cause is just an old problem of dependant global
    objects: construction order.

    // snip begin+++ appender.cpp

    namespace log4cpp {
    Appender::AppenderMap* Appender::_allAppenders;
    threading::Mutex Appender::_appenderMapMutex; <----
    this mutex object poses the problem!!!

    // snip end---

    The order of initialization is undefined across compilation
    units. So if someone uses (like me) static log instance
    references at global files scope they must be initialized at the
    beginning.

    example:

    static log4cpp::Category& = log4cpp::Category::getInstance
    () .... constructs a new Appender, which gets added to map
    of appenders.
    If the mutex, which is used to protect the map is not yet
    constructed (in another compiltion unit) -> *boom*.

    Solutions: not elegant ones yet ...

    1.) instead of "threading::Mutex
    Appender::_appenderMapMutex;"

    use "first time access - first init"

    threading::Mutex& _getAppenderMapMutex()
    {
    static threading::Mutex mutex;
    return mutex;
    }

    2.) #pragma init_seg (non portable)

    Regards,

    Anastasius Focht

     
  • Steve Pole

    Steve Pole - 2003-04-10

    Logged In: YES
    user_id=455201

    Yep, same thing here on W2K/VC6. The reason why I went
    from 0.2.7 to 0.3.4b was the garbled output in my multi-
    threaded application, so I guess I'm just gonna go back and
    try to live with it...

     

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.