[Log4cplus-devel] [ log4cplus-Support Requests-3570926 ] Buffer overrun with Hello World example
Logging Framework for C++
Brought to you by:
wilx
From: SourceForge.net <no...@so...> - 2012-09-23 04:00:11
|
Support Requests item #3570926, was opened at 2012-09-22 21:00 Message generated for change (Tracker Item Submitted) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=429074&aid=3570926&group_id=40830 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: v1.1.0 Status: Open Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Nobody/Anonymous (nobody) Summary: Buffer overrun with Hello World example Initial Comment: I'm attempting to use logforcplus in my first c++ project in over ten years, so please assume I might have done something simple wrong. I cannot get the Hello World example working without buffer overrun errors. I downloaded log4cplus-1.1.0-rc10. I used VS2010 to open the sln in msvc10 folder, set log4cplus project to Debug_Unicode, and compile. I created a new project directory log4cplusDemo, with subdirectories bin, include, lib, and src. "Bin" contains log4cplusUD.dll and pdb, "include" contains include\log4cplus, and "lib" contains log4cplusUD.lib. I used VS2012 to create a new C++ Win32 exe in the "src" directory. Project Properties..Configuration Properties..General..Character Set is Unicode. Configuration Properties..C/C++..General..Additional Include Directories has a reference to "include". Configuration Properties..Linker..General..Additional Library Directories has a reference to "lib". Linker..Input..Additional Dependencies has a reference to "log4cplusUD.lib". Trying the hello world example resulted in a buffer overrun error. I was able to expand the macro and isolate the failing line. Replacing it with a hardcoded string works, but causes a buffer overrun when main() exits. What am I doing wrong? #include "stdafx.h" #include <log4cplus/logger.h> #include <log4cplus/loggingmacros.h> #include <log4cplus/configurator.h> using namespace log4cplus; int _tmain(int argc, _TCHAR* argv[]) { BasicConfigurator config; config.configure(); Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("main")); // This causes buffer overrun on this line // LOG4CPLUS_WARN(logger, LOG4CPLUS_TEXT("Hello, World!")); // This works (by commenting out original call to .str() and sending a string directly), // but buffer overflow error occurs on return statement. do { log4cplus::Logger const & _l = log4cplus::detail::macros_get_logger (logger); // I can't figure out this macro, and it's just checking if the desired log level is enabled so comment out // if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( //_l.isEnabledFor (log4cplus::logLevel), logLevel)) { log4cplus::tostringstream & _log4cplus_buf = log4cplus::detail::get_macro_body_oss (); _log4cplus_buf << LOG4CPLUS_TEXT("Hello, World!"); log4cplus::detail::macro_forced_log (_l, log4cplus::WARN_LOG_LEVEL, // This causes buffer overflow error, replace with string directly //_log4cplus_buf.str(), L"Hello world!", __FILE__, __LINE__, LOG4CPLUS_MACRO_FUNCTION () ); //} } while (0); getchar(); return 0; } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=429074&aid=3570926&group_id=40830 |