Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access violation reading location - non-terminated string (unreadable memory)

I'm using log4cplus library and I can't get logging to work.

I use this code:

PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log.properties"));
Logger g_logger = Logger::getInstance(LOG4CPLUS_TEXT("mylogger"));

LOG4CPLUS_WARN(g_logger, LOG4CPLUS_TEXT("test test test"));

And it breaks at LOG4CPLUS_WARN with error: Access violation reading location

This is my Call Stack:

msvcp110d.dll!std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >::egptr() Line 236    C++
ProjectClientd.exe!std::basic_stringbuf<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::str() Line 103 C++
ProjectClientd.exe!std::basic_ostringstream<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::str() Line 553 C++
>   ProjectClientd.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 55    C++
ProjectClientd.exe!__tmainCRTStartup() Line 528 C
ProjectClientd.exe!wWinMainCRTStartup() Line 377    C

where wWinMain ... line 55 is a place where LOG4CPLUS_WARN is being called.

I have checked what's wrong with this basic_ostringstream and it seems that something is messed up with encoding or something: enter image description here

Non-terminated string (unreadable memory) and a whole bunch of strange letters at the end of my string? What may cause it?

like image 985
Piotr Chojnacki Avatar asked Nov 12 '22 21:11

Piotr Chojnacki


1 Answers

Have you solved your problem? I have the same error, and I've noticed, that I linked with release version of log4cplusU.dll while application was built in debug, so linkage with log4cplusUD.dll for debug configuration solved my issue

like image 74
yudjin Avatar answered Nov 15 '22 06:11

yudjin