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

Exception lifetime confusion can cause the application to crash

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.5.0, 3.6.0, 3.7.0
    • 3.7.1, 3.8.0
    • CMS Impl, Decaf
    • None

    Description

      In changeset #139775, the "decaf::lang::Exception" class changed its ownership policy for its std::exception cause. Before the changeset, Exception class would clone the cause, and after the change, the Exception class took ownership of the std::exception.
      However, many code paths still assume that the Exception class will clone the std::exception, which makes the application crash when a std::exception is thrown in their protected region.
      Here is a incomplete list of places in the code that makes this bad assumption (line numbers from version 3.7.0):
      -decaf\util\concurrent\FutureTask.h, line 272
      -decaf\util\concurrent\FutureTask.h, line 301
      -decaf\util\concurrent\ThreadPoolExecutor.cpp, line 742
      -activemq\core\ActiveMQTransactionContext.cpp, line 646
      -activemq\core\ActiveMQTransactionContext.cpp, line 757
      -decaf\internal\net\tcp\TcpSocket.cpp, line 361

      Note that subclasses of Exception may also be affected, since they normally forward the cause to their parent.
      The comments on many of those classes still wrongly indicates that the cause will be cloned. For example, the comments for Exception::Exception(const std::exception*) is inconsistent with the comments for Exception::initCause()

      An easy way to reproduce the bug is to throw a std::exception from an onException callback, which should make the application crash.

      Attachments

        1. Test-AMQCPP-490.patch
          4 kB
          Jonathan Fortier

        Activity

          People

            tabish Timothy A. Bish
            jonathan fortier Jonathan Fortier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: