closing ressources after an IOException crashes the app
-------------------------------------------------------

                 Key: AMQCPP-126
                 URL: https://issues.apache.org/activemq/browse/AMQCPP-126
             Project: ActiveMQ C++ Client
          Issue Type: Bug
          Components: CMS Impl
    Affects Versions: 2.0.1
         Environment: tested on Windows 2000
            Reporter: olivier renaud
            Assignee: Nathan Mittler


When a network error occurs, I want to clean up all the created objects and 
close the connection and the session.
So, when I catch an exception (activemq::io::IOException), either created by 
from producer.send, or by an asynchronous notification on the ExceptionListener 
object set for the Connection.

However, closing ressources (Consumer, Producer, or Session) always crash the 
application. This can be seen with the Example code in ActiveMQCPP sources :

- run the example program so that it connects to a distant host (not localhost)
- physically unplug the network (or shutdown the network connection), and wait

The program stops with the following message :

{quote}
...
Sent message #334 from thread 1216
Sent message #335 from thread 1216
Message #335 Received: Hello world! from thread 1216
JMS Exception occured.  Shutting down client.
response from futureResponse was invalid
        FILE: ..\src\main\activemq\transport\ResponseCorrelator.cpp, LINE: 145
        FILE: ..\src\main\activemq\transport\ResponseCorrelator.cpp, LINE: 152
        FILE: ..\src\main\activemq\connector\openwire\OpenWireFormatNegotiator.c
pp, LINE: 105
        FILE: ..\src\main\activemq\connector\openwire\OpenWireConnector.cpp, LIN
E: 1468
        FILE: ..\src\main\activemq\connector\openwire\OpenWireConnector.cpp, LIN
E: 928
        FILE: ..\src\main\activemq\core\ActiveMQSession.cpp, LINE: 703
        FILE: ..\src\main\activemq\core\ActiveMQProducer.cpp, LINE: 194
        FILE: ..\src\main\activemq\core\ActiveMQProducer.cpp, LINE: 149
        FILE: ..\src\main\activemq\core\ActiveMQProducer.cpp, LINE: 108
-----------------------------------------------------
Finished with the example, ignore errors from this
point on as the sockets breaks when we shutdown.
=====================================================
{quote}

And it generates an access violation, with the following stack trace :

{quote}
        NTDLL.DLL!784905a5()    
        [Les frames ci-dessous sont peut-ĂȘtre incorrects et/ou manquants, aucun 
symbole chargé pour NTDLL.DLL]  
        NTDLL.DLL!7847bd5a()    
        NTDLL.DLL!7847bf68()    
        NTDLL.DLL!7847bf98()    
        NTDLL.DLL!784ab63e()    
        NTDLL.DLL!7847bf68()    
        NTDLL.DLL!7847bf98()    
        NTDLL.DLL!7847c1ea()    
        msvcr80d.dll!1024db9c()         
        msvcr80d.dll!1020faa5()         
        msvcr80d.dll!1020f839()         
        msvcr80d.dll!1020f7b9()         
        msvcr80d.dll!1026902f()         
>       vs2005-activemq-example.exe!std::_Iterator_base::_Adopt(const 
> std::_Container_base * _Parent=0x00033540)  Ligne 166     C++
        vs2005-activemq-example.exe!std::_Vector_const_iterator<unsigned 
char,std::allocator<unsigned char> >::_Vector_const_iterator<unsigned 
char,std::allocator<unsigned char> >(unsigned char * _Ptr=0x00cb5f21, const 
std::_Container_base * _Pvector=0x00033540)  Ligne 73        C++
        vs2005-activemq-example.exe!std::_Vector_iterator<unsigned 
char,std::allocator<unsigned char> >::_Vector_iterator<unsigned 
char,std::allocator<unsigned char> >(unsigned char * _Ptr=0x00000009, const 
std::_Container_base * _Pvector=0x000336dc)  Ligne 309   C++
        00cb5f18()      
        vs2005-activemq-example.exe!std::vector<unsigned 
char,std::allocator<unsigned char> >::push_back(const unsigned char & _Val=0)  
Ligne 800 + 0x24 octets C++
        
vs2005-activemq-example.exe!activemq::io::ByteArrayOutputStream::write(unsigned 
char c=0)  Ligne 54     C++
        vs2005-activemq-example.exe!activemq::io::DataOutputStream::write(const 
unsigned char c=0)  Ligne 43    C++
        
vs2005-activemq-example.exe!activemq::io::DataOutputStream::writeUnsignedShort(unsigned
 short value=36)  Ligne 126      C++
        
vs2005-activemq-example.exe!activemq::io::DataOutputStream::writeUTF(const 
std::basic_string<char,std::char_traits<char>,std::allocator<char> > & 
value="4bf52ac5-df69-4b18-b28d-669a36b2b7f9")  Ligne 217      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::marshal::BaseDataStreamMarshaller::looseMarshalString(std::basic_string<char,std::char_traits<char>,std::allocator<char>
 > value="4bf52ac5-df69-4b18-b28d-669a36b2b7f9", activemq::io::DataOutputStream 
* dataOut=0x00cb5df8)  Ligne 307     C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::marshal::v2::ConsumerIdMarshaller::looseMarshal(activemq::connector::openwire::OpenWireFormat
 * wireFormat=0x0031e150, 
activemq::connector::openwire::commands::DataStructure * 
dataStructure=0x00cb6288, activemq::io::DataOutputStream * dataOut=0x00cb5df8)  
Ligne 131    C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireFormat::looseMarshalNestedObject(activemq::connector::openwire::commands::DataStructure
 * o=0x00cb6288, activemq::io::DataOutputStream * dataOut=0x00cb5df8)  Ligne 
458      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::marshal::BaseDataStreamMarshaller::looseMarshalCachedObject(activemq::connector::openwire::OpenWireFormat
 * wireFormat=0x0031e150, 
activemq::connector::openwire::commands::DataStructure * data=0x00cb6288, 
activemq::io::DataOutputStream * dataOut=0x00cb5df8)  Ligne 98 + 0x10 octets    
C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::marshal::v2::RemoveInfoMarshaller::looseMarshal(activemq::connector::openwire::OpenWireFormat
 * wireFormat=0x0031e150, 
activemq::connector::openwire::commands::DataStructure * 
dataStructure=0x00034e7c, activemq::io::DataOutputStream * dataOut=0x00cb5df8)  
Ligne 124 + 0x35 octets      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireFormat::marshal(activemq::transport::Command
 * command=0x00034e78, activemq::io::DataOutputStream * dataOut=0x0031fd98)  
Ligne 153   C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireCommandWriter::writeCommand(activemq::transport::Command
 * command=0x00034e78)  Ligne 72     C++
        
vs2005-activemq-example.exe!activemq::transport::IOTransport::oneway(activemq::transport::Command
 * command=0x00034e78)  Ligne 83 + 0x1d octets C++
        
vs2005-activemq-example.exe!activemq::transport::TransportFilter::oneway(activemq::transport::Command
 * command=0x00034e78)  Ligne 147  C++
        
vs2005-activemq-example.exe!activemq::transport::ResponseCorrelator::oneway(activemq::transport::Command
 * command=0x00034e78)  Ligne 87 + 0x1d octets  C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireFormatNegotiator::oneway(activemq::transport::Command
 * command=0x00034e78)  Ligne 73 + 0x1d octets  C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::oneway(activemq::transport::Command
 * command=0x00034e78)  Ligne 1436 + 0x1d octets       C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::disposeOf(activemq::connector::openwire::commands::DataStructure
 * objectId=0x00c91b40)  Ligne 1483       C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::closeResource(activemq::connector::ConnectorResource
 * resource=0x00c919b8)  Ligne 1315 + 0xf octets      C++
        
vs2005-activemq-example.exe!activemq::connector::BaseConnectorResource::close() 
 Ligne 60       C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::~OpenWireConsumerInfo()
  Ligne 53      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::`scalar
 deleting destructor'()  + 0xf octets   C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::closeResource(activemq::connector::ConnectorResource
 * resource=0x00c919b8)  Ligne 1318 + 0x32 octets     C++
        
vs2005-activemq-example.exe!activemq::connector::BaseConnectorResource::close() 
 Ligne 60       C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::~OpenWireConsumerInfo()
  Ligne 53      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::`scalar
 deleting destructor'()  + 0xf octets   C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::closeResource(activemq::connector::ConnectorResource
 * resource=0x00c919b8)  Ligne 1318 + 0x32 octets     C++
        
vs2005-activemq-example.exe!activemq::connector::BaseConnectorResource::close() 
 Ligne 60       C++
        ...
        [ here, the same message repeated about 50 times ]
        ...
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::~OpenWireConsumerInfo()
  Ligne 53      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::`scalar
 deleting destructor'()  + 0xf octets   C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::closeResource(activemq::connector::ConnectorResource
 * resource=0x00c919b8)  Ligne 1318 + 0x32 octets     C++
        
vs2005-activemq-example.exe!activemq::connector::BaseConnectorResource::close() 
 Ligne 60       C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::~OpenWireConsumerInfo()
  Ligne 53      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::`scalar
 deleting destructor'()  + 0xf octets   C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::closeResource(activemq::connector::ConnectorResource
 * resource=0x00c919b8)  Ligne 1318 + 0x32 octets     C++
        
vs2005-activemq-example.exe!activemq::connector::BaseConnectorResource::close() 
 Ligne 60       C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::~OpenWireConsumerInfo()
  Ligne 53      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::`scalar
 deleting destructor'()  + 0xf octets   C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::closeResource(activemq::connector::ConnectorResource
 * resource=0x00c919b8)  Ligne 1318 + 0x32 octets     C++
        
vs2005-activemq-example.exe!activemq::connector::BaseConnectorResource::close() 
 Ligne 60       C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::~OpenWireConsumerInfo()
  Ligne 53      C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConsumerInfo::`scalar
 deleting destructor'()  + 0xf octets   C++
        
vs2005-activemq-example.exe!activemq::connector::openwire::OpenWireConnector::closeResource(activemq::connector::ConnectorResource
 * resource=0x00c919b8)  Ligne 1318 + 0x32 octets     C++
        
vs2005-activemq-example.exe!activemq::connector::BaseConnectorResource::close() 
 Ligne 60       C++
        vs2005-activemq-example.exe!activemq::core::ActiveMQConsumer::close()  
Ligne 87 + 0x19 octets   C++
        
vs2005-activemq-example.exe!activemq::core::ActiveMQConsumer::~ActiveMQConsumer()
  Ligne 64     C++
        vs2005-activemq-example.exe!activemq::core::ActiveMQConsumer::`scalar 
deleting destructor'()  + 0xf octets      C++
        vs2005-activemq-example.exe!HelloWorldConsumer::cleanup()  Ligne 269 + 
0x40 octets      C++
        vs2005-activemq-example.exe!HelloWorldConsumer::~HelloWorldConsumer()  
Ligne 180        C++
        vs2005-activemq-example.exe!main(int argc=1, char * * argv=0x00315b30)  
Ligne 340 + 0x2d octets C++
        vs2005-activemq-example.exe!__tmainCRTStartup()  Ligne 586 + 0x19 
octets        C
        vs2005-activemq-example.exe!mainCRTStartup()  Ligne 403 C
        KERNEL32.DLL!77e98989()         
        NTDLL.DLL!78465c09()    
{quote}

I see no way of properly closing ressources when a disconnection happen

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to