[
https://issues.apache.org/jira/browse/LOGCXX-422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13885415#comment-13885415
]
Thorsten Schöning commented on LOGCXX-422:
------------------------------------------
I think the problem is returning i in findMillisecondStart: Regarding
LOG4CXX-420 if the milliseconds overlap i is an index within the milliseconds
already whereas millisecondFormat assumes to always have a buffer with at least
3 characters for milliseconds to fill. This doesn't hold anymore if
milliseconds overlap because the returned start index may be 21 instead of 20.
I would suspect this advances more and more until the 50 characters for the
cache are reached or stuff like that.
Could you please try the following instead of returning i in
findMillisecondStart:
return i - (3 - (formatted.length() - i));
The returned index need to take into account how far it already is within the
millisceonds and reduce by that count.
I'm currently unable to compile trunk and the problem didn't occur in my
companies branch for years, therefore I would be glad fi you could test the fix
on your own. If it works, I will commit it.
Thanks!
> Sporadic crash in CachedDateFormat::millisecondFormat()
> -------------------------------------------------------
>
> Key: LOGCXX-422
> URL: https://issues.apache.org/jira/browse/LOGCXX-422
> Project: Log4cxx
> Issue Type: Bug
> Components: Core
> Affects Versions: 0.10.1
> Environment: Windows 7, Visual C++ 2008 (SP1)
> Reporter: Jörg Hansen
> Assignee: Thorsten Schöning
> Priority: Critical
>
> The method CachedDateFormat::findMillisecondStart() was changed in rev
> 1559522 for LOG4CXX-420.
> Since then I experience sporadic crashes in the method
> CachedDateFormat::millisecondFormat(). Further investigation showed that the
> specified parameter 'buf' is sometimes undefined, so any try to write
> sporadically fails.
> I have a debugging session open with the crash at the time of this writing.
> The current log message is "Current spot Reichenspergerplatz - EBP at (3,13)
> of entry 582" and should be written to a ConsoleAppender. The current
> conversion pattern is "%d %p [%c] %m%n". The call stack at the crash is
> (sorry, german version of vc2008):
> log4cxx.dll!log4cxx::pattern::CachedDateFormat::millisecondFormat(int
> millis=147018584,
> std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >
> & buf=<Schlechtes Ptr>, int offset=22) Zeile 236 + 0x12 Bytes
> log4cxx.dll!log4cxx::pattern::CachedDateFormat::format(std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
> > & buf="", __int64 now=1390993757666876, log4cxx::helpers::Pool & p={...})
> Zeile 189 + 0x21 Bytes
> log4cxx.dll!log4cxx::pattern::DatePatternConverter::format(const
> log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> & event={...},
> std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >
> & toAppendTo="", log4cxx::helpers::Pool & p={...}) Zeile 104 + 0x23 Bytes
> log4cxx.dll!log4cxx::PatternLayout::format(std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
> > & output="", const
> log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> & event={...},
> log4cxx::helpers::Pool & pool={...}) Zeile 91
> log4cxx.dll!log4cxx::WriterAppender::subAppend(const
> log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> & event={...},
> log4cxx::helpers::Pool & p={...}) Zeile 217
> log4cxx.dll!log4cxx::WriterAppender::append(const
> log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> & event={...},
> log4cxx::helpers::Pool & pool1={...}) Zeile 88 + 0x13 Bytes
> log4cxx.dll!log4cxx::AppenderSkeleton::doAppend(const
> log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> & event={...},
> log4cxx::helpers::Pool & pool1={...}) Zeile 143
> log4cxx.dll!log4cxx::helpers::AppenderAttachableImpl::appendLoopOnAppenders(const
> log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> & event={...},
> log4cxx::helpers::Pool & p={...}) Zeile 69 + 0x29 Bytes
> log4cxx.dll!log4cxx::Logger::callAppenders(const
> log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> & event={...},
> log4cxx::helpers::Pool & p={...}) Zeile 97 + 0x12 Bytes
> log4cxx.dll!log4cxx::Logger::forcedLog(const
> log4cxx::helpers::ObjectPtrT<log4cxx::Level> & level1={...}, const
> std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
> message="Current spot Reichenspergerplatz - EBP at (3,13) of entry 582",
> const log4cxx::spi::LocationInfo & location={...}) Zeile 129
> Translation help:
> Zeile = line
> Schlechtes Ptr = bad pointer
> Please call back if you need further information.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)