Menu

#79 Read access violation at program exit

open
nobody
None
5
2004-11-22
2004-11-22
Anonymous
No

There is an order of call Category::getInstance and
Appender::ctor so program will be terminated at exit.

More precisely if I call Category::getInstance first (in
order to create own category), further I create new
appender (by new operator) the following internal
functions will be called in specified order:

1. // Due to Category::getInstance
HierarchyMaintainer&
HierarchyMaintainer::getDefaultMaintainer() {
static HierarchyMaintainer _defaultMaintainer;

return _defaultMaintainer;
}

2. // Due to Appender::ctor
Appender::AppenderMap& Appender::_getAllAppenders
() {
static Appender::AppenderMap _allAppenders;

return _allAppenders;
}

Thus destructor for _allAppenders will be called before
dtor for defaultMaintainer.

As I have seen,
HierarchyMaintainer::~HierarchyMaintainer
calls ::_getAllAppenders through shutdown() /
Category::removeAllAppenders, so _getAllAppenders
refers to destroyed _allAppenders.

Discussion


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.