logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noam Rathaus <no...@beyondsecurity.com>
Subject log4cxx crash after call to setFile
Date Sun, 17 Oct 2010 13:53:18 GMT
Hi,

I am trying to use the following code in Visual Studio 2010, under the
previous version of Visual Studio it worked without a hitch, now it
crashes:
LogString strLayout(LOG4CXX_STR("[%d{yyyy-MM-dd HH:mm:ss}, %p]%m%n"));
log4cxx::PatternLayoutPtr FileLayout = new log4cxx::PatternLayout(strLayout);

log4cxx::RollingFileAppenderPtr pFileAppMain(new
log4cxx::RollingFileAppender());

pFileAppMain->setLayout(FileLayout);
pFileAppMain->setFile(log4cxx::helpers::Transcoder::decode(m_Filename.c_str()));


m_Filename is set as:
static std::string CLogger::m_Filename = "";

And assigned a value of "c:\LOGLOCATION\" just before the above code is called.

The code variable is set as static as the CLogger code is called by
several functions, so I want the log object to be shared.

This is the crash:
       GUI.exe!_CrtIsValidHeapPointer(const void * pUserData)  Line
2036       C++
       GUI.exe!_free_dbg_nolock(void * pUserData, int nBlockUse)  Line 1322
+ 0x9 bytes     C++
       GUI.exe!_free_dbg(void * pUserData, int nBlockUse)  Line 1265 +
0xd bytes       C++
       GUI.exe!operator delete(void * p)  Line 347 + 0xb bytes C++
       GUI.exe!std::allocator<wchar_t>::deallocate(wchar_t * _Ptr, unsigned
int __formal)  Line 182 + 0x9 bytes     C++
       GUI.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>::_Tidy(bool _Built, unsigned int _Newsize)  Line 1998 C++
       GUI.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>::~basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>()  Line 755   C++
       GUI.exe!CLogger::initLog4cxx(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> logThreads, std::basic_string<char,std::char_traits<char>,std::allocator<char>
> logExceptions)  Line 95       C++


I believe the problem is because std::string is going out of context
and the log4cxx hasn't made a copy of it.

Thanks,
Noam Rathaus

Mime
View raw message