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 Peter Gejgus <ge...@canex.sk> on 2009/04/28 13:33:07 UTC

log4cxx release issue in VS2005

Hello,

I have log4cxx 0.10.0. I use it as a release dll in my project compiled 
under VS2005. When my project is built in debug, log4cxx has no problem. 
But when I built my project as release, I got a following issue:

"A buffer overrun has occurred in foo.exe which has corrupted the 
program's internal state. Press Break to debug the program or Continue 
to terminate the program."

I only use this lines of code to invoke logging services:

    PropertyConfigurator::configure("log4cxx.properties");
    LoggerPtr logger = log4cxx::Logger::getRootLogger();

    LOG4CXX_DEBUG(logger, "Test log...");

Is there any bug in log4cxx?  I used  the same VS2005 Code generation->Runtime 
library settings in log4cxx dll and my project (exe).

Best Regards,
Peter


Re: log4cxx release issue in VS2005

Posted by Cory Riddell <co...@codeware.com>.
Are you using the Geodesic package?

Peter gejgus wrote:
> Yes, I got a crash (buffer overrun) after 1-2 seconds. My Visual
> Studio 2005 is up to date. I have SP1 installed. Call stack seems like
> this:
>
>     bbb.exe!__crt_debugger_hook()     Unknown
> >    bbb.exe!__report_gsfailure()  Line 315 + 0x7 bytes    C
>     bbb.exe!wmain(int argc=1, wchar_t * * argv=0x00b65938)  Line 29 +
> 0x18 bytes    C++
>     bbb.exe!__tmainCRTStartup()  Line 594 + 0x17 bytes    C
>     kernel32.dll!7c817077()         [Frames below may be incorrect
> and/or missing, no symbols loaded for kernel32.dll]   
> Can you send me  your complete test application (sources + project
> files)? Or  I can send you mine, but I don't know your email address.
> Maybe you have some different switch for compiler.
>
> Peter
>
> Cory Riddell wrote:
>> When I run with your properties file, I get this output:
>>   2009-04-28 10:16:52,904 [0x00000b74] .\Test2.cpp(20) - Test log...
>>
>> And I am doing a release build. You say to wait for a while and a crash
>> will occur. With that short program I posted, you are getting a crash
>> right away, correct?
>>
>> Is your Visual Studio up to date? I know we had some problems with
>> VS2005 before SP1, but since then it has been pretty stable. We are
>> running on fully patched 32-bit XP Pro machines.
>>
>> You could try stepping through the code with a debugger attached to your
>> release build. If you do that, please post the entire call stack at the
>> point the overrun is caught. I'm not 100% sure, but there may be some
>> stack safety switches in the compiler options that are worth trying
>> as well.
>>
>> I'm not sure what else to recommend. We are using it and haven't had any
>> problems so far.
>>
>> Cory
>>
>>
>>
>> Peter Gejgus wrote:
>>  
>>> My log4cxx.properties looks like this one:
>>>
>>> log4j.rootLogger=DEBUG, stdout, R, D
>>> log4j.logger.test.a.b.c=WARN
>>> log4j.logger.filelogger=WARN, R
>>> log4j.additivity.filelogger=FALSE
>>>
>>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>>> log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5l - %m%n
>>>
>>> log4j.appender.R=org.apache.log4j.RollingFileAppender
>>> log4j.appender.R.File=ObjectCounterFilter.log
>>> #log4j.appender.R.MaxFileSize=5MB
>>> log4j.appender.R.MaxFileSize=500KB
>>> log4j.appender.R.MaxBackupIndex=5
>>> log4j.appender.R.layout=org.apache.log4j.PatternLayout
>>> log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p - %m%n
>>>
>>> log4j.appender.D=org.apache.log4j.OutputDebugStringAppender
>>> log4j.appender.D.layout=org.apache.log4j.PatternLayout
>>> log4j.appender.D.layout.ConversionPattern=%d [%t] %-5p - %m%n
>>>
>>> I tried to use your code and I got crash again. Did you try it in
>>> release? Wait for a while and crash will occur. I don't mix a debug
>>> dll with a release exe.
>>>
>>> Peter
>>>
>>> Cory Riddell wrote:
>>>    
>>>> What does your log4cxx.properties file look like?
>>>>
>>>> You say you used the same settings building the dll and the exe. Does
>>>> this mean that you are certain you aren't mixing a debug dll with a
>>>> release exe?
>>>>
>>>> Cory
>>>>
>>>> Peter Gejgus wrote:
>>>>  
>>>>      
>>>>> My question is the same as the Paul's question at
>>>>> http://www.dreamcubes.com/blog/?itemid=43. But I see no meaningful
>>>>> answer there.
>>>>>
>>>>> Cory Riddell wrote:
>>>>>           
>>>>>> Peter Gejgus wrote:
>>>>>>  
>>>>>>               
>>>>>>> I have log4cxx 0.10.0. I use it as a release dll in my project
>>>>>>> compiled under VS2005. When my project is built in debug,
>>>>>>> log4cxx has
>>>>>>> no problem. But when I built my project as release, I got a
>>>>>>> following
>>>>>>> issue:
>>>>>>>
>>>>>>> "A buffer overrun has occurred in foo.exe which has corrupted the
>>>>>>> program's internal state. Press Break to debug the program or
>>>>>>> Continue
>>>>>>> to terminate the program."
>>>>>>>
>>>>>>>                         
>>>>>> So, if you press break and enter the debugger, can you see that the
>>>>>> buffer overrun is in log4cxx code?
>>>>>>
>>>>>> My first suspicion would be that you have an uninitialized variable
>>>>>> somewhere in your program. For some reason, VS initializes
>>>>>> variables in
>>>>>> a debug build and not at all in a release build.
>>>>>>
>>>>>> cory
>>>>>>
>>>>>>
>>>>>>                   
>>>>>             
>>>     
>
>

Re: log4cxx release issue in VS2005

Posted by Peter gejgus <ge...@canex.sk>.
Yes, I got a crash (buffer overrun) after 1-2 seconds. My Visual Studio 
2005 is up to date. I have SP1 installed. Call stack seems like this:

     bbb.exe!__crt_debugger_hook()     Unknown
 >    bbb.exe!__report_gsfailure()  Line 315 + 0x7 bytes    C
     bbb.exe!wmain(int argc=1, wchar_t * * argv=0x00b65938)  Line 29 + 
0x18 bytes    C++
     bbb.exe!__tmainCRTStartup()  Line 594 + 0x17 bytes    C
     kernel32.dll!7c817077()     
     [Frames below may be incorrect and/or missing, no symbols loaded 
for kernel32.dll]    

Can you send me  your complete test application (sources + project 
files)? Or  I can send you mine, but I don't know your email address. 
Maybe you have some different switch for compiler.

Peter
 
Cory Riddell wrote:
> When I run with your properties file, I get this output:
>   2009-04-28 10:16:52,904 [0x00000b74] .\Test2.cpp(20) - Test log...
>
> And I am doing a release build. You say to wait for a while and a crash
> will occur. With that short program I posted, you are getting a crash
> right away, correct?
>
> Is your Visual Studio up to date? I know we had some problems with
> VS2005 before SP1, but since then it has been pretty stable. We are
> running on fully patched 32-bit XP Pro machines.
>
> You could try stepping through the code with a debugger attached to your
> release build. If you do that, please post the entire call stack at the
> point the overrun is caught. I'm not 100% sure, but there may be some
> stack safety switches in the compiler options that are worth trying as well.
>
> I'm not sure what else to recommend. We are using it and haven't had any
> problems so far.
>
> Cory
>
>
>
> Peter Gejgus wrote:
>   
>> My log4cxx.properties looks like this one:
>>
>> log4j.rootLogger=DEBUG, stdout, R, D
>> log4j.logger.test.a.b.c=WARN
>> log4j.logger.filelogger=WARN, R
>> log4j.additivity.filelogger=FALSE
>>
>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>> log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5l - %m%n
>>
>> log4j.appender.R=org.apache.log4j.RollingFileAppender
>> log4j.appender.R.File=ObjectCounterFilter.log
>> #log4j.appender.R.MaxFileSize=5MB
>> log4j.appender.R.MaxFileSize=500KB
>> log4j.appender.R.MaxBackupIndex=5
>> log4j.appender.R.layout=org.apache.log4j.PatternLayout
>> log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p - %m%n
>>
>> log4j.appender.D=org.apache.log4j.OutputDebugStringAppender
>> log4j.appender.D.layout=org.apache.log4j.PatternLayout
>> log4j.appender.D.layout.ConversionPattern=%d [%t] %-5p - %m%n
>>
>> I tried to use your code and I got crash again. Did you try it in
>> release? Wait for a while and crash will occur. I don't mix a debug
>> dll with a release exe.
>>
>> Peter
>>
>> Cory Riddell wrote:
>>     
>>> What does your log4cxx.properties file look like?
>>>
>>> You say you used the same settings building the dll and the exe. Does
>>> this mean that you are certain you aren't mixing a debug dll with a
>>> release exe?
>>>
>>> Cory
>>>
>>> Peter Gejgus wrote:
>>>  
>>>       
>>>> My question is the same as the Paul's question at
>>>> http://www.dreamcubes.com/blog/?itemid=43. But I see no meaningful
>>>> answer there.
>>>>
>>>> Cory Riddell wrote:
>>>>    
>>>>         
>>>>> Peter Gejgus wrote:
>>>>>  
>>>>>      
>>>>>           
>>>>>> I have log4cxx 0.10.0. I use it as a release dll in my project
>>>>>> compiled under VS2005. When my project is built in debug, log4cxx has
>>>>>> no problem. But when I built my project as release, I got a following
>>>>>> issue:
>>>>>>
>>>>>> "A buffer overrun has occurred in foo.exe which has corrupted the
>>>>>> program's internal state. Press Break to debug the program or
>>>>>> Continue
>>>>>> to terminate the program."
>>>>>>
>>>>>>             
>>>>>>             
>>>>> So, if you press break and enter the debugger, can you see that the
>>>>> buffer overrun is in log4cxx code?
>>>>>
>>>>> My first suspicion would be that you have an uninitialized variable
>>>>> somewhere in your program. For some reason, VS initializes
>>>>> variables in
>>>>> a debug build and not at all in a release build.
>>>>>
>>>>> cory
>>>>>
>>>>>
>>>>>         
>>>>>           
>>>>     
>>>>         
>>     


Re: log4cxx release issue in VS2005

Posted by Cory Riddell <co...@codeware.com>.
When I run with your properties file, I get this output:
  2009-04-28 10:16:52,904 [0x00000b74] .\Test2.cpp(20) - Test log...

And I am doing a release build. You say to wait for a while and a crash
will occur. With that short program I posted, you are getting a crash
right away, correct?

Is your Visual Studio up to date? I know we had some problems with
VS2005 before SP1, but since then it has been pretty stable. We are
running on fully patched 32-bit XP Pro machines.

You could try stepping through the code with a debugger attached to your
release build. If you do that, please post the entire call stack at the
point the overrun is caught. I'm not 100% sure, but there may be some
stack safety switches in the compiler options that are worth trying as well.

I'm not sure what else to recommend. We are using it and haven't had any
problems so far.

Cory



Peter Gejgus wrote:
> My log4cxx.properties looks like this one:
>
> log4j.rootLogger=DEBUG, stdout, R, D
> log4j.logger.test.a.b.c=WARN
> log4j.logger.filelogger=WARN, R
> log4j.additivity.filelogger=FALSE
>
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5l - %m%n
>
> log4j.appender.R=org.apache.log4j.RollingFileAppender
> log4j.appender.R.File=ObjectCounterFilter.log
> #log4j.appender.R.MaxFileSize=5MB
> log4j.appender.R.MaxFileSize=500KB
> log4j.appender.R.MaxBackupIndex=5
> log4j.appender.R.layout=org.apache.log4j.PatternLayout
> log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p - %m%n
>
> log4j.appender.D=org.apache.log4j.OutputDebugStringAppender
> log4j.appender.D.layout=org.apache.log4j.PatternLayout
> log4j.appender.D.layout.ConversionPattern=%d [%t] %-5p - %m%n
>
> I tried to use your code and I got crash again. Did you try it in
> release? Wait for a while and crash will occur. I don't mix a debug
> dll with a release exe.
>
> Peter
>
> Cory Riddell wrote:
>> What does your log4cxx.properties file look like?
>>
>> You say you used the same settings building the dll and the exe. Does
>> this mean that you are certain you aren't mixing a debug dll with a
>> release exe?
>>
>> Cory
>>
>> Peter Gejgus wrote:
>>  
>>> My question is the same as the Paul's question at
>>> http://www.dreamcubes.com/blog/?itemid=43. But I see no meaningful
>>> answer there.
>>>
>>> Cory Riddell wrote:
>>>    
>>>> Peter Gejgus wrote:
>>>>  
>>>>      
>>>>> I have log4cxx 0.10.0. I use it as a release dll in my project
>>>>> compiled under VS2005. When my project is built in debug, log4cxx has
>>>>> no problem. But when I built my project as release, I got a following
>>>>> issue:
>>>>>
>>>>> "A buffer overrun has occurred in foo.exe which has corrupted the
>>>>> program's internal state. Press Break to debug the program or
>>>>> Continue
>>>>> to terminate the program."
>>>>>
>>>>>             
>>>> So, if you press break and enter the debugger, can you see that the
>>>> buffer overrun is in log4cxx code?
>>>>
>>>> My first suspicion would be that you have an uninitialized variable
>>>> somewhere in your program. For some reason, VS initializes
>>>> variables in
>>>> a debug build and not at all in a release build.
>>>>
>>>> cory
>>>>
>>>>
>>>>         
>>>     
>
>

Re: log4cxx release issue in VS2005

Posted by Peter Gejgus <ge...@canex.sk>.
My log4cxx.properties looks like this one:

log4j.rootLogger=DEBUG, stdout, R, D
log4j.logger.test.a.b.c=WARN
log4j.logger.filelogger=WARN, R
log4j.additivity.filelogger=FALSE

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5l - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=ObjectCounterFilter.log
#log4j.appender.R.MaxFileSize=5MB
log4j.appender.R.MaxFileSize=500KB
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p - %m%n

log4j.appender.D=org.apache.log4j.OutputDebugStringAppender
log4j.appender.D.layout=org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern=%d [%t] %-5p - %m%n

I tried to use your code and I got crash again. Did you try it in 
release? Wait for a while and crash will occur. I don't mix a debug dll 
with a release exe.

Peter

Cory Riddell wrote:
> What does your log4cxx.properties file look like?
>
> You say you used the same settings building the dll and the exe. Does
> this mean that you are certain you aren't mixing a debug dll with a
> release exe?
>
> Cory
>
> Peter Gejgus wrote:
>   
>> My question is the same as the Paul's question at
>> http://www.dreamcubes.com/blog/?itemid=43. But I see no meaningful
>> answer there.
>>
>> Cory Riddell wrote:
>>     
>>> Peter Gejgus wrote:
>>>  
>>>       
>>>> I have log4cxx 0.10.0. I use it as a release dll in my project
>>>> compiled under VS2005. When my project is built in debug, log4cxx has
>>>> no problem. But when I built my project as release, I got a following
>>>> issue:
>>>>
>>>> "A buffer overrun has occurred in foo.exe which has corrupted the
>>>> program's internal state. Press Break to debug the program or Continue
>>>> to terminate the program."
>>>>
>>>>     
>>>>         
>>> So, if you press break and enter the debugger, can you see that the
>>> buffer overrun is in log4cxx code?
>>>
>>> My first suspicion would be that you have an uninitialized variable
>>> somewhere in your program. For some reason, VS initializes variables in
>>> a debug build and not at all in a release build.
>>>
>>> cory
>>>
>>>
>>>   
>>>       
>>     


Re: log4cxx release issue in VS2005

Posted by Cory Riddell <co...@codeware.com>.
What does your log4cxx.properties file look like?

You say you used the same settings building the dll and the exe. Does
this mean that you are certain you aren't mixing a debug dll with a
release exe?

Cory

Peter Gejgus wrote:
> My question is the same as the Paul's question at
> http://www.dreamcubes.com/blog/?itemid=43. But I see no meaningful
> answer there.
>
> Cory Riddell wrote:
>> Peter Gejgus wrote:
>>  
>>> I have log4cxx 0.10.0. I use it as a release dll in my project
>>> compiled under VS2005. When my project is built in debug, log4cxx has
>>> no problem. But when I built my project as release, I got a following
>>> issue:
>>>
>>> "A buffer overrun has occurred in foo.exe which has corrupted the
>>> program's internal state. Press Break to debug the program or Continue
>>> to terminate the program."
>>>
>>>     
>>
>>
>> So, if you press break and enter the debugger, can you see that the
>> buffer overrun is in log4cxx code?
>>
>> My first suspicion would be that you have an uninitialized variable
>> somewhere in your program. For some reason, VS initializes variables in
>> a debug build and not at all in a release build.
>>
>> cory
>>
>>
>>   
>
>

Re: log4cxx release issue in VS2005

Posted by Cory Riddell <co...@codeware.com>.
Here's the program I wrote based on your first post:

--------------------------------------------------------------
#include "stdafx.h"
#include "log4cxx/logger.h"
#include "log4cxx/propertyconfigurator.h"
#include "log4cxx/helpers/exception.h"

using namespace log4cxx;
using namespace log4cxx::helpers;


int _tmain(int argc, _TCHAR* argv[])
{
    int result = EXIT_SUCCESS;
    try
    {
        PropertyConfigurator::configure("log4cxx.properties");
        LoggerPtr logger = log4cxx::Logger::getRootLogger();
        LOG4CXX_DEBUG(logger, "Test log...");
    }
    catch(Exception&)
    {
        result = EXIT_FAILURE;
    }
    return result;
}
--------------------------------------------------------------

And the properties file:
--------------------------------------------------------------
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
--------------------------------------------------------------

And when I run it, I get this output:
  0    [0x00000828] DEBUG root null - Test log...

Cory



Peter Gejgus wrote:
> My question is the same as the Paul's question at
> http://www.dreamcubes.com/blog/?itemid=43. But I see no meaningful
> answer there.
>
> Cory Riddell wrote:
>> Peter Gejgus wrote:
>>  
>>> I have log4cxx 0.10.0. I use it as a release dll in my project
>>> compiled under VS2005. When my project is built in debug, log4cxx has
>>> no problem. But when I built my project as release, I got a following
>>> issue:
>>>
>>> "A buffer overrun has occurred in foo.exe which has corrupted the
>>> program's internal state. Press Break to debug the program or Continue
>>> to terminate the program."
>>>
>>>     
>>
>>
>> So, if you press break and enter the debugger, can you see that the
>> buffer overrun is in log4cxx code?
>>
>> My first suspicion would be that you have an uninitialized variable
>> somewhere in your program. For some reason, VS initializes variables in
>> a debug build and not at all in a release build.
>>
>> cory
>>
>>
>>   
>
>

Re: log4cxx release issue in VS2005

Posted by Peter Gejgus <ge...@canex.sk>.
My question is the same as the Paul's question at 
http://www.dreamcubes.com/blog/?itemid=43. But I see no meaningful 
answer there.

Cory Riddell wrote:
> Peter Gejgus wrote:
>   
>> I have log4cxx 0.10.0. I use it as a release dll in my project
>> compiled under VS2005. When my project is built in debug, log4cxx has
>> no problem. But when I built my project as release, I got a following
>> issue:
>>
>> "A buffer overrun has occurred in foo.exe which has corrupted the
>> program's internal state. Press Break to debug the program or Continue
>> to terminate the program."
>>
>>     
>
>
> So, if you press break and enter the debugger, can you see that the
> buffer overrun is in log4cxx code?
>
> My first suspicion would be that you have an uninitialized variable
> somewhere in your program. For some reason, VS initializes variables in
> a debug build and not at all in a release build.
>
> cory
>
>
>   


Re: log4cxx release issue in VS2005

Posted by Cory Riddell <co...@codeware.com>.
Peter Gejgus wrote:
> I have log4cxx 0.10.0. I use it as a release dll in my project
> compiled under VS2005. When my project is built in debug, log4cxx has
> no problem. But when I built my project as release, I got a following
> issue:
>
> "A buffer overrun has occurred in foo.exe which has corrupted the
> program's internal state. Press Break to debug the program or Continue
> to terminate the program."
>


So, if you press break and enter the debugger, can you see that the
buffer overrun is in log4cxx code?

My first suspicion would be that you have an uninitialized variable
somewhere in your program. For some reason, VS initializes variables in
a debug build and not at all in a release build.

cory