logo       

RE: Logging before main() crashes in 0.9.7: msg#00037

Subject: RE: Logging before main() crashes in 0.9.7
About using 0.9.8 -- my company is a bit reluctant (understandably) to use a version of a library that has not yet been released, and is constantly being changed.  As soon as the new version is released, we plan to switch over to it.
 
Anyway, here are the details on the crash I'm experiencing.  I would certainly appreciate it if you could show me how to prevent it:
 
In a function called before main(), Logger::getLogger() is called.
 
First, log4cxx produces this error message:
"You have tried to set a null level to root."
This happens in rootcategory.cpp, line 40
It happens because we are trying to set a level using the static Level pointer Level::DEBUG.p, which is NULL.
 
Here is the stack trace at this point:
log4cxx::spi::RootCategory::setLevel(const log4cxx::helpers::ObjectPtrT<log4cxx::Level> & {...}) line 40
log4cxx::spi::RootCategory::RootCategory(const log4cxx::helpers::ObjectPtrT<log4cxx::Level> & {...}, unsigned int 1) line 29
log4cxx::LogManager::getLoggerRepository() line 70 + 94 bytes
log4cxx::LogManager::getLogger(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d30b9 "TraceTst.BeforeMain"}) line 124 + 15 bytes
log4cxx::Logger::getLogger(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d30b9 "TraceTst.BeforeMain"}) line 473 + 13 bytes
BeforeMain() line 44 + 357 bytes
$E90() line 32 + 29 bytes
$E91() + 29 bytes
_initterm(void (void)* * 0x00716160 $S92, void (void)* * 0x00716a7c ___xc_z) line 525
_cinit() line 192 + 15 bytes
mainCRTStartup() line 205
KERNEL32! 7c816d4f()
Then, the application crashes with the following message:
"Unhandled exception in TraceTst.exe: 0xC0000005: Access Violation."
This happens in class.cpp, line 79.
It happens because we are trying to dereference the global classMap pointer registry, which is NULL:
const Class * clazz = (*registry)[StringHelper::toLowerCase(strippedClassName)];
Here is the stack trace at the point of the crash:
log4cxx::helpers::Class::forName(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d62d1 "org.apache.log4j.xml.DOMConfigurator"}) line 79
log4cxx::helpers::Loader::loadClass(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d62d1 "org.apache.log4j.xml.DOMConfigurator"}) line 56 + 9 bytes
log4cxx::helpers::OptionConverter::instantiateByClassName(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d62d1 "org.apache.log4j.xml.DOMConfigurator"}, const log4cxx::helpers::Class & {...}, const log4cxx::helpers::ObjectPtrT<log4cxx::helpers::Object> & {...}) line 362 + 9 bytes
log4cxx::helpers::OptionConverter::selectAndConfigure(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d63e1 "TraceTst.cfg"}, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d6359 "org.apache.log4j.xml.DOMConfigurator"}, log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggerRepository> & {...}) line 399 + 46 bytes
log4cxx::LogManager::getLoggerRepository() line 99 + 55 bytes
log4cxx::LogManager::getLogger(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d30b9 "TraceTst.BeforeMain"}) line 124 + 15 bytes
log4cxx::Logger::getLogger(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & {0x003d30b9 "TraceTst.BeforeMain"}) line 473 + 13 bytes
BeforeMain() line 44 + 357 bytes
$E90() line 32 + 29 bytes
$E91() + 29 bytes
_initterm(void (void)* * 0x00716160 $S92, void (void)* * 0x00716a7c ___xc_z) line 525
_cinit() line 192 + 15 bytes
mainCRTStartup() line 205
KERNEL32! 7c816d4f()
Thanks for your help,
 
Moshe


From: matthew.kanwisher@xxxxxxxxx [mailto:matthew.kanwisher@xxxxxxxxx] On Behalf Of Matthew Kanwisher
Sent: Sunday, April 23, 2006 6:14 AM
To: Log4CXX User
Subject: Re: Logging before main() crashes in 0.9.7

Yuk 0.9.7 isnt a good version you should go with 0.9.8 in generall,however the crash your talking about is fairly simple, I found it before on the group, if you post what line its crashing on maybee I can give some insight.  I think some variable has to be forced to be loaded before anything else cause the load order gets borked on msvc compiles for some reason.

On 4/22/06, Moshe Matitya <Moshe.Matitya@xxxxxxxxxx> wrote:
I am using log4cxx 0.9.7 on Windows with MSVC 6.0 SP6.  I have found that attempting to log anything before main() is executed (e.g., in a function called from the initializer of a global static variable) will always result in a crash.  This is apparently happening because of some log4cxx static data which has not yet been initialized.  Has this problem been fixed in 0.9.8?
 
Thanks,
 
Moshe Z. Matitya

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe