Details
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.