logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marshall Powers" <mpow...@appsecinc.com>
Subject RE: AIX segfault
Date Fri, 29 Jun 2007 15:55:16 GMT
I noticed that the program was crashing in iconv_open("UTF-8", "ISO8859-1").
Out of curiosity, I tried calling that function from my own program, before
"new RollingFileAppender()", to see if it was purely a problem with my IBM
iconv. The segfault vanished. Here is a revised program:

_main.cpp_

#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/rolling/rollingfileappender.h>
#include <iconv.h>

using namespace log4cxx;
using namespace log4cxx::rolling;

int main(int argc, char * argv[]) {
    
    LoggerPtr root = Logger::getRootLogger();
    BasicConfigurator::configure();
    
    
    RollingFileAppenderPtr rfa;
    iconv_t cd = iconv_open("UTF-8", "ISO8859-1");    
    if(argc > 1) {
        rfa = new RollingFileAppender();
        if(argc > 3)
        {
            iconv_open("UTF-8", "ISO8859-1");
        }
        
        if(argc > 2)
        {
            rfa = new RollingFileAppender();
        }
    }
    
    
    LOG4CXX_DEBUG(root, "HELLO WORLD!");

    return 0;
}


And here is an example of what happens when I run it:

bash-3.00$ ./testptr
60 [0x1] DEBUG root null - HELLO WORLD!
bash-3.00$ ./testptr 1
2 [0x1] DEBUG root null - HELLO WORLD!
bash-3.00$ ./testptr 1 2
Segmentation fault
bash-3.00$ ./testptr 1 2 4
2 [0x1] DEBUG root null - HELLO WORLD!

Note how in the case of argc == 3 (two arguments) there is a second call to
new RollingFileAppender() without a preceding call to iconv_open, and the
segfault returns. I have tried this with other strings for iconv_open, and
it appears that the arguments must be "UTF-8" and "ISO8859-1" in order to
prevent the segfault.


I don't know if that helps diagnose the problem, but it seemed interesting.



Thanks for your help,
Marshall


Mime
View raw message