Vladislav Krejcirik | 25 May 2012 09:11
Picon

Log4cxx and memory read problem while program is ending

Hi All,
I got very simple program in C++ which uses log4cxx for logging. I
have successfuly build log4cxx in VS 2008 and linked log4cxx.lib and
log4cxx.dll to my project. I have problem while my program is closing.
I received error message:

Unhandled exception at 0x10171754 in Log4cxxTest.exe: 0xC0000005:
Access violation reading location 0xfeeefefe.

The memory couldn't to be read.

Is there any solution how can I clean log4cxx correctly when my
program is ending? I closed my app by CTRL+C.

The code is very simple:

#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/helpers/exception.h>

using namespace log4cxx;
using namespace log4cxx::xml;
using namespace log4cxx::helpers;

LoggerPtr logger(Logger::getLogger("Log4cxxTest"));

BOOL CtrlHandler( DWORD fdwCtrlType )
{
	switch( fdwCtrlType )
(Continue reading)

Thorsten Schöning | 25 May 2012 09:46
Picon

Re: Log4cxx and memory read problem while program is ending

Guten Tag Vladislav Krejcirik,
am Freitag, 25. Mai 2012 um 09:11 schrieben Sie:

> Unhandled exception at 0x10171754 in Log4cxxTest.exe: 0xC0000005:
> Access violation reading location 0xfeeefefe.

There are known problems in the shutdown of log4cxx, the following may
help. I had to uncomment the call to apr_terminate in some classes.

http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200901.mbox/%3C4975157F.8070001 <at> purplescarab.com%3E

Mit freundlichen Grüßen,

Thorsten Schöning

--

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening <at> AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon.............030-2 1001-310
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow

Vladislav Krejcirik | 25 May 2012 10:02
Picon

Re: Log4cxx and memory read problem while program is ending

Hi,
Thanks for reply! I'm not sure, but I changed code for handling CTRL+C
and issue looks like fixed. May be it was not problem with log4cxx..
Code looks now like this:

#include <windows.h>
#include <stdio.h>

#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/helpers/exception.h>

using namespace log4cxx;
using namespace log4cxx::xml;
using namespace log4cxx::helpers;

LoggerPtr logger(Logger::getLogger("Log4cxxTest"));

static volatile bool g_exit = false;

static BOOL WINAPI console_ctrl_handler(DWORD dwCtrlType)
{
  g_exit = true;
  return TRUE;
}

int _tmain(int argc, _TCHAR* argv[])
{
		int result = EXIT_SUCCESS;
(Continue reading)

Mehrwash Faruqi | 25 May 2012 10:16
Picon

Re: Log4cxx and memory read problem while program is ending



On Fri, May 25, 2012 at 1:02 PM, Vladislav Krejcirik <vkrejcirik <at> gmail.com> wrote:
Hi,
Thanks for reply! I'm not sure, but I changed code for handling CTRL+C
and issue looks like fixed. May be it was not problem with log4cxx..
Code looks now like this:

#include <windows.h>
#include <stdio.h>

#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/helpers/exception.h>

using namespace log4cxx;
using namespace log4cxx::xml;
using namespace log4cxx::helpers;


LoggerPtr logger(Logger::getLogger("Log4cxxTest"));

static volatile bool g_exit = false;

static BOOL WINAPI console_ctrl_handler(DWORD dwCtrlType)
{
 g_exit = true;
 return TRUE;
}


int _tmain(int argc, _TCHAR* argv[])
{
               int result = EXIT_SUCCESS;
       try
       {
               // Load configuration file
               //DOMConfigurator::configure("PIAdapterLogConfig.xml");
               //PropertyConfigurator::configure("PIAdapterLogConfig.xml");
               BasicConfigurator::configure();

 SetConsoleCtrlHandler(console_ctrl_handler, TRUE);

 while (!g_exit);

       }
       catch(Exception&)
       {
               result = EXIT_FAILURE;
       }

       return result;
}



On Fri, May 25, 2012 at 9:46 AM, Thorsten Schöning
<tschoening <at> am-soft.de> wrote:
> Guten Tag Vladislav Krejcirik,
> am Freitag, 25. Mai 2012 um 09:11 schrieben Sie:
>
>> Unhandled exception at 0x10171754 in Log4cxxTest.exe: 0xC0000005:
>> Access violation reading location 0xfeeefefe.
>
> There are known problems in the shutdown of log4cxx, the following may
> help. I had to uncomment the call to apr_terminate in some classes.
>
> http://mail-archives.apache.org/mod_mbox/logging-log4cxx-dev/200901.mbox/%3C4975157F.8070001 <at> purplescarab.com%3E
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail:Thorsten.Schoening <at> AM-SoFT.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon.............030-2 1001-310
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow
>



--
/**************************************/
Best regards / S pozdravem
Vladislav Krejčiřík

http://www.vkrejcirik.info



--
Mehrwash Faruqi
Thorsten Schöning | 25 May 2012 10:21
Picon

Re: Log4cxx and memory read problem while program is ending

Guten Tag Vladislav Krejcirik,
am Freitag, 25. Mai 2012 um 10:02 schrieben Sie:

> Thanks for reply! I'm not sure, but I changed code for handling CTRL+C
> and issue looks like fixed. May be it was not problem with log4cxx..

I don't know about that handler but in the former version you logged
on CTRL_SHUTDOWN_EVENT and maybe this event was fired after log4xx was
already destructed right before the application shutdown.

Mit freundlichen Grüßen,

Thorsten Schöning

--

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening <at> AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon.............030-2 1001-310
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow


Gmane