You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Laurie Mercer <ls...@gmail.com> on 2009/05/20 10:41:07 UTC

PatternLayout / Access Violation on win32 Release build only

Log4cxx users,

I have a project using log4cxx. Originally this was a C++ STL application
that was built using ant/VS2003. Log4cxx was statically linked into the
project. This has been running without problems for over a year.

I have recently upgraded studio to 2008 (version 9), and am having problems
with my Release build. The problem is that when my PatternLayout has params
set, an unhandled exception caused by an Access Violation is thrown. This is
unrecoverable and the application exits. The same code executes without
throwing this exception in the Debug build. I have commented out the param
setting code and the next line causes the problem.

Whilst the logger works fine in the Debug build, there is a problem on
application shutdown: a Run-time check failure #0 as a value of ESP was not
properly saved across a function call is reported. This then causes Access
Violations until the program exits. This may be unrelated.

I have used the original code that we checked out of trunk (an early 0.10.0
version) and the latest version found on the website. I have been using APR
1.2.12 and APR-UTIL 1.2.12. I have build both using ant to build everything
(in a ms visual studio command prompt), and using ant to generate the
project files, then VS 2008 to build the libraries. The same problem is
present in all of these builds.

I have built and linked Log4cxx to my application as a dll and statically,
both times using the Multithreaded Dll compiler option (the same as my
application). The same behaviour is present: release builds crashing on
startup, debug on exit. When building log4cxx, I have been building apr and
apr-util with the same compiler options as log4cxx.

Has anyone seen this problem before? Any ideas?

Regards,
Laurie Mercer.
________________________lsmercer@gmail.com

Re: PatternLayout / Access Violation on win32 Release build only

Posted by Laurie Mercer <ls...@gmail.com>.
FYI I have resolved this problem.
Visual Studio 2008 (version 9) enables checked iterators by default. This is
the equivalent of setting the _SECURE_SCL=1 preprocessor definition.

During the upgrade of our project from studio 2003 we disabled this option,
to avoid problems with our legacy code (and boost), by defining the
preprocessor definition:_SECURE_SCL=0.

When log4cxx is built, using both Ant and VS2009, as this flag is not set,
it defaults to _SECURE_SCL=1.

Studio will allow the linking libraries with conflicting iterator
implementations and will not report an error, but at runtime this will throw
an access violation. This was only thrown in the release configuration (i.e.
not the debug configuration) presumably as the debug heap has memory padding
etc.

To fix I used ant to build the VS2009 vcproj files and modified them to
include the _SECURE_SCL=0 preprocessor definition, built the libs and
relinked to my application. Sorted.

On Wed, May 20, 2009 at 9:41 AM, Laurie Mercer <ls...@gmail.com> wrote:

> Log4cxx users,
>
> I have a project using log4cxx. Originally this was a C++ STL application
> that was built using ant/VS2003. Log4cxx was statically linked into the
> project. This has been running without problems for over a year.
>
> I have recently upgraded studio to 2008 (version 9), and am having problems
> with my Release build. The problem is that when my PatternLayout has params
> set, an unhandled exception caused by an Access Violation is thrown. This is
> unrecoverable and the application exits. The same code executes without
> throwing this exception in the Debug build. I have commented out the param
> setting code and the next line causes the problem.
>
> Whilst the logger works fine in the Debug build, there is a problem on
> application shutdown: a Run-time check failure #0 as a value of ESP was not
> properly saved across a function call is reported. This then causes Access
> Violations until the program exits. This may be unrelated.
>
> I have used the original code that we checked out of trunk (an early 0.10.0
> version) and the latest version found on the website. I have been using APR
> 1.2.12 and APR-UTIL 1.2.12. I have build both using ant to build everything
> (in a ms visual studio command prompt), and using ant to generate the
> project files, then VS 2008 to build the libraries. The same problem is
> present in all of these builds.
>
> I have built and linked Log4cxx to my application as a dll and statically,
> both times using the Multithreaded Dll compiler option (the same as my
> application). The same behaviour is present: release builds crashing on
> startup, debug on exit. When building log4cxx, I have been building apr and
> apr-util with the same compiler options as log4cxx.
>
> Has anyone seen this problem before? Any ideas?
>
> Regards,
> Laurie Mercer.
> ________________________lsmercer@gmail.com
>



-- 
Laurie Mercer
_________________________
lsmercer@gmail.com