[ https://issues.apache.org/activemq/browse/AMQCPP-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_39435 ]
Albert Strasheim commented on AMQCPP-128: ----------------------------------------- I look at a bit at the "Expression: list erase iterator outside range" crash. In the case I looked at, one thread was receiving from a socket. Another thread was waiting on a mutex and a third thread was doing notifyAll on that same mutex. The thread waiting on the mutex was doing so from ActiveMQSessionExecutor::run(). Stack trace: > vs2005-activemq-example.exe!std::list<void *,std::allocator<void *> > >::_Insert(std::list<void *,std::allocator<void *> >::_Iterator<1> > _Where=..., void * const & _Val=0x00f2fe30) Line 706 + 0xf bytes C++ kernel32.dll!7c802532() vs2005-activemq-example.exe!activemq::concurrent::Mutex::wait(unsigned long millisecs=4294967295) Line 199 C++ vs2005-activemq-example.exe!activemq::concurrent::Mutex::wait() Line 106 C++ vs2005-activemq-example.exe!activemq::core::ActiveMQSessionExecutor::run() Line 231 C++ vs2005-activemq-example.exe!activemq::concurrent::Thread::runCallback(void * param=0x00d31d10) Line 152 + 0x13 bytes C++ msvcr80d.dll!_callthreadstartex() Line 348 + 0xf bytes C msvcr80d.dll!_threadstartex(void * ptd=0x00d31a90) Line 331 C The thread doing notifyAll was doing so from ActiveMQSessionExecutor::stop(), called as part of a rollback. Stack trace (the _Debug_message call at the top of the stack is the MSVC checked iterators kicking in to report the error): > msvcp80d.dll!std::_Debug_message(const wchar_t * message=0x006a0fb0, > const wchar_t * file=0x006a0d88, unsigned int line=776) Line 24 C++ vs2005-activemq-example.exe!std::list<void *,std::allocator<void *> >::erase(std::list<void *,std::allocator<void *> >::_Iterator<1> _Where=0xcdcdcdcd) Line 776 + 0x15 bytes C++ vs2005-activemq-example.exe!std::list<void *,std::allocator<void *> >::pop_front() Line 649 + 0x20 bytes C++ vs2005-activemq-example.exe!activemq::concurrent::Mutex::notifyAll() Line 258 C++ vs2005-activemq-example.exe!activemq::core::ActiveMQSessionExecutor::stop() Line 154 C++ vs2005-activemq-example.exe!activemq::core::ActiveMQSession::stop() Line 849 C++ vs2005-activemq-example.exe!activemq::core::ActiveMQTransaction::rollback() Line 239 C++ vs2005-activemq-example.exe!activemq::core::ActiveMQSession::rollback() Line 169 + 0x19 bytes C++ vs2005-activemq-example.exe!test_transaction(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & url="tcp://localhost:61613?wireFormat=stomp") Line 56 + 0x15 bytes C++ vs2005-activemq-example.exe!main(int argc=1, char * * argv=0x00355898) Line 85 + 0x30 bytes C++ vs2005-activemq-example.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C vs2005-activemq-example.exe!mainCRTStartup() Line 414 C The strange part: it looks like both threads synchronize on this mutex before they call wait or notifyAll, so why are they both inside the synchronized block at the same time? > Transacted session crashes or loses messages > -------------------------------------------- > > Key: AMQCPP-128 > URL: https://issues.apache.org/activemq/browse/AMQCPP-128 > Project: ActiveMQ C++ Client > Issue Type: Bug > Affects Versions: 2.1 > Reporter: Albert Strasheim > Assignee: Timothy Bish > Fix For: 2.1 > > Attachments: main.cpp > > > Attached is some code that does a few things with transacted sessions, in a > loop. This sometimes reproduces the crash I mentioned in one of my latest > comments in AMQCPP-122. > I'm testing on Windows XP SP2 with Visual Studio 8 on Core 2 Duo machine. > I've also seen all of the following happen in subsequent runs of the code: > - Where I expect to receive a message, nothing turns up (even with a long > timeout period). Cleanup goes fine. > - Where I expect to receive a message, nothing turns up. Cleanup hangs. > - Sometimes it prints: > Mutex::unlock - Failed, not Lock Owner! > FILE: ..\src\main\activemq\concurrent\Mutex.cpp, LINE: 83 > FILE: activemq-cpp\src\main\activemq/concurrent/Lock.h, LINE: 110 > FILE: ..\src\main\activemq\core\ActiveMQConsumer.cpp, LINE: 443 > FILE: ..\src\main\activemq\core\ActiveMQSessionExecutor.cpp, LINE: 192 > and keeps on going > - Sometimes it crashes with the following when running a Debug build on > Windows: > --------------------------- > Microsoft Visual C++ Debug Library > --------------------------- > Debug Assertion Failed! > Program: ... > File: C:\Program Files\Microsoft Visual Studio 8\VC\include\list > Line: 776 > Expression: list erase iterator outside range > For information on how your program can cause an assertion > failure, see the Visual C++ documentation on asserts. > (Press Retry to debug the application) > --------------------------- > Abort Retry Ignore > --------------------------- > - Sometimes it crashes with something along these lines: > --------------------------- > vs2005-activemq-example.exe - Application Error > --------------------------- > The instruction at "0x0053dd80" referenced memory at "0xdddddddd". The memory > could not be "read". > Click on OK to terminate the program > Click on CANCEL to debug the program > --------------------------- > OK Cancel > --------------------------- > The relevant thread's stack trace looks like this: > > vs2005-activemq-example.exe!activemq::core::ActiveMQSession::close() > > Line 110 + 0x8 bytes C++ > > vs2005-activemq-example.exe!activemq::core::ActiveMQSession::~ActiveMQSession() > Line 74 + 0x8 bytes C++ > vs2005-activemq-example.exe!activemq::core::ActiveMQSession::`scalar > deleting destructor'() + 0xf bytes C++ > vs2005-activemq-example.exe!test_transaction(const > std::basic_string<char,std::char_traits<char>,std::allocator<char> > & > url="tcp://localhost:61613?wireFormat=stomp") Line 78 + 0x37 bytes C++ > vs2005-activemq-example.exe!main(int argc=1, char * * argv=0x003558c8) > Line 85 + 0x30 bytes C++ > vs2005-activemq-example.exe!__tmainCRTStartup() Line 597 + 0x19 bytes > C > vs2005-activemq-example.exe!mainCRTStartup() Line 414 C > It crashes where it's doing resource->close() because resource points to > garbage. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.