Uploaded image for project: 'ActiveMQ C++ Client'
  1. ActiveMQ C++ Client
  2. AMQCPP-257

Segfault on session or connection cleanup

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 3.1
    • CMS Impl, Openwire
    • None
    • Windows Visual Studio 2005

    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

      { 155a157,159 > }

      > /* 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 );

      Attachments

        1. main.cpp
          12 kB
          Ben Watrous
        2. ActiveMQSession.cpp
          37 kB
          Ben Watrous

        Activity

          People

            tabish Timothy A. Bish
            bwatrous Ben Watrous
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: