logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Moshe Matitya" <Moshe.Mati...@Kayote.com>
Subject RE: Logging before main() crashes in 0.9.7
Date Sun, 23 Apr 2006 10:41:44 GMT
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@gmail.com
[mailto:matthew.kanwisher@gmail.com] 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@kayote.com> 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
		



Mime
View raw message