Details
Description
I recently moved up to ActiveMQ CPP 3.0 (and now 3.0.1) from 2.2 to take advantage of the failover transport, and discovered a segfault during testing. It may be related to my test procedure, but I have found a quick patch to activemq/core/ActiveMQSession.cpp that seems to resolve the issue.
It appears that in some cases of connection loss, the connection->disposeOf() call may throw. In which case the Session is left in an invalid state - the producers or consumer that caused the exception is still in the list, but it has already been destroyed. This leads to an invalid pointer access later on.
In the current test, the exception is thrown because the connection to the broker has been dropped so disposeOf fails.
Test Procedure:
Open the attached example (modified version of the basic sample) in the Visual Studio debugger.
Set a breakpoint at the "producer->send( message );" line.
Run to breakpoint.
To simulate a broken connection, connect to broker via JMX console and execute the JMX "Stop" operation on the Connector for the producer.
Continue the debugger.
( Note: I "Purge" the TEST.FOO queue between runs since messages may sometimes be left in queue during this type of testing. )
Suggested Patch to ActiveMQSession.cpp:
153a154
> try
> /* Absorb */
> AMQ_CATCHALL_NOTHROW()
1042a1047
> this->consumers.remove( id );
1045c1050
< this->consumers.remove( id );
—
> // this->consumers.remove( id );
1065a1071
> this->producers.remove( id );
1068c1074
< this->producers.remove( id );
—
> // this->producers.remove( id );