[PATCH] [CPP] Exception thrown by MamaTransport destructor


Adrienne Ambrose <AAmbrose@...>
 

Testing -
This is not OS Dependant
This applies to C++ only 

Only the mamatransport exception was possible to recreate
To test this simply get build and run the attached application, MamaTransportTest.cpp 

Pre-patch this will core with a backtrace similar to this: 

#0 0x00000037e6c30265 in raise () from /lib64/libc.so.6 
#1 0x00000037e6c31d10 in abort () from /lib64/libc.so.6 
#2 0x00000037f9abed94 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib64/libstdc++.so.6 
#3 0x00000037f9abce46 in ?? () from /usr/lib64/libstdc++.so.6 
#4 0x00000037f9abce73 in std::terminate() () from /usr/lib64/libstdc++.so.6 
#5 0x00000037f9abcf71 in __cxa_throw () from /usr/lib64/libstdc++.so.6 
#6 0x00000000004056b0 in Wombat::mamaTry(._10) (status=MAMA_STATUS_NO_BRIDGE_IMPL) at /var/userspace/gmolloy/MAMA6/src/products/mama/c_cpp/src/cpp/mamacppinternal.h:56 
#7 0x00000000004051ea in Wombat::MamaTransport::~MamaTransport (this=0xfa06010, __in_chrg=<value optimized out>) 
    at /var/userspace/gmolloy/MAMA6/src/products/mama/c_cpp/src/cpp/MamaTransport.cpp:324 
#8 0x00000000004045ce in std::auto_ptr<Wombat::MamaTransport>::~auto_ptr() () 
#9 0x000000000040454a in TransportTest() () 
#10 0x000000000040457b in main () 

Post-patch the application will not core (the app does nothing so it will simply return)

For the rest of the changes regression testing will ensure no negative effects.

 

 

From 0d885d4fb20f7d58983cc09a230dc26d3cc857a5 Mon Sep 17 00:00:00 2001

From: A Ambrose <aambrose@...>

Date: Mon, 23 Jun 2014 16:57:15 +0100

Subject: [PATCH 2/2] Exception thrown by Mama destructors

 

Some of the MAMA C++ classes can throw exceptions from the destructor which is not allowed.

[OMAMA-261]

Signed-off-by: A Ambrose <aambrose@...>

---

mama/c_cpp/src/cpp/MamaDictionary.cpp | 8 ++++----

mama/c_cpp/src/cpp/MamaMsgQual.cpp    | 4 +++-

mama/c_cpp/src/cpp/MamaSource.cpp     | 3 ++-

mama/c_cpp/src/cpp/MamaTransport.cpp  | 4 ++--

4 files changed, 11 insertions(+), 8 deletions(-)

 

diff --git a/mama/c_cpp/src/cpp/MamaDictionary.cpp b/mama/c_cpp/src/cpp/MamaDictionary.cpp

index 0471b90..6fa8fdb 100644

--- a/mama/c_cpp/src/cpp/MamaDictionary.cpp

+++ b/mama/c_cpp/src/cpp/MamaDictionary.cpp

@@ -387,20 +387,20 @@ DictionaryImpl::~DictionaryImpl (void)

     for (int i = 0; i <= getMaxFid(); i++)

     {

         mamaFieldDescriptor fd = 0;

-        mamaTryIgnoreNotFound (mamaDictionary_getFieldDescriptorByFid (

+        mamaDictionary_getFieldDescriptorByFid (

                 mDictionary,

                 &fd,

-                i));

+                i);

         if (fd)

         {

             void* closureData;

-            mamaTry (mamaFieldDescriptor_getClosure (fd, &closureData));

+            mamaFieldDescriptor_getClosure (fd, &closureData);

             MamaFieldDescriptor* cppFd = (MamaFieldDescriptor*)closureData;

             delete cppFd;

         }

     }

 

-    mamaTry (mamaDictionary_destroy (mDictionary));

+    mamaDictionary_destroy (mDictionary);

     mDictionary = 0;

}

 

diff --git a/mama/c_cpp/src/cpp/MamaMsgQual.cpp b/mama/c_cpp/src/cpp/MamaMsgQual.cpp

index 5217c10..8372cf4 100644

--- a/mama/c_cpp/src/cpp/MamaMsgQual.cpp

+++ b/mama/c_cpp/src/cpp/MamaMsgQual.cpp

@@ -50,7 +50,9 @@ namespace Wombat

         {

             delete myStrRep;

         }

-        mamaTry (mamaMsgQual_destroy (myMsgQual));

+

+        if (NULL != myMsgQual)

+            mamaMsgQual_destroy (myMsgQual);

     }

 

     MamaMsgQual& MamaMsgQual::operator= (const MamaMsgQual& rhs)

diff --git a/mama/c_cpp/src/cpp/MamaSource.cpp b/mama/c_cpp/src/cpp/MamaSource.cpp

index c5a5e6c..afbb305 100644

--- a/mama/c_cpp/src/cpp/MamaSource.cpp

+++ b/mama/c_cpp/src/cpp/MamaSource.cpp

@@ -148,7 +148,8 @@ namespace Wombat

 

     MamaSource::~MamaSource ()

     {

-        mamaTry (mamaSource_destroy (mySource));

+        if (NULL != mySource)

+            mamaSource_destroy (mySource);

 

         if (mySubs)

         {

diff --git a/mama/c_cpp/src/cpp/MamaTransport.cpp b/mama/c_cpp/src/cpp/MamaTransport.cpp

index a6823cd..259bfe1 100644

--- a/mama/c_cpp/src/cpp/MamaTransport.cpp

+++ b/mama/c_cpp/src/cpp/MamaTransport.cpp

@@ -319,9 +319,9 @@ namespace Wombat

                                    {

                                                    delete mPimpl->mCallback;

                                    }

-            if (mPimpl->mDeleteCTransport)

+            if (mPimpl->mDeleteCTransport && NULL != mTransport)

             {

-                mamaTry (mamaTransport_destroy (mTransport));

+                mamaTransport_destroy (mTransport);

             }

             delete mPimpl;

             mPimpl = NULL;

--

1.8.3.1

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


Damian Maguire <DMaguire@...>
 

Cheers Adrienne, raised this as Bugzilla BZ129.

D

From: Adrienne Ambrose <AAmbrose@...>
Date: Tuesday, June 24, 2014 10:09 AM
To: "openmama-dev@..." <openmama-dev@...>
Subject: [Openmama-dev] [PATCH] [CPP] Exception thrown by MamaTransport destructor

Testing -
This is not OS Dependant
This applies to C++ only 

Only the mamatransport exception was possible to recreate
To test this simply get build and run the attached application, MamaTransportTest.cpp 

Pre-patch this will core with a backtrace similar to this: 

#0 0x00000037e6c30265 in raise () from /lib64/libc.so.6 
#1 0x00000037e6c31d10 in abort () from /lib64/libc.so.6 
#2 0x00000037f9abed94 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib64/libstdc++.so.6 
#3 0x00000037f9abce46 in ?? () from /usr/lib64/libstdc++.so.6 
#4 0x00000037f9abce73 in std::terminate() () from /usr/lib64/libstdc++.so.6 
#5 0x00000037f9abcf71 in __cxa_throw () from /usr/lib64/libstdc++.so.6 
#6 0x00000000004056b0 in Wombat::mamaTry(._10) (status=MAMA_STATUS_NO_BRIDGE_IMPL) at /var/userspace/gmolloy/MAMA6/src/products/mama/c_cpp/src/cpp/mamacppinternal.h:56 
#7 0x00000000004051ea in Wombat::MamaTransport::~MamaTransport (this=0xfa06010, __in_chrg=<value optimized out>) 
    at /var/userspace/gmolloy/MAMA6/src/products/mama/c_cpp/src/cpp/MamaTransport.cpp:324 
#8 0x00000000004045ce in std::auto_ptr<Wombat::MamaTransport>::~auto_ptr() () 
#9 0x000000000040454a in TransportTest() () 
#10 0x000000000040457b in main () 

Post-patch the application will not core (the app does nothing so it will simply return)

For the rest of the changes regression testing will ensure no negative effects.

 

 

From 0d885d4fb20f7d58983cc09a230dc26d3cc857a5 Mon Sep 17 00:00:00 2001

From: A Ambrose <aambrose@...>

Date: Mon, 23 Jun 2014 16:57:15 +0100

Subject: [PATCH 2/2] Exception thrown by Mama destructors

 

Some of the MAMA C++ classes can throw exceptions from the destructor which is not allowed.

[OMAMA-261]

Signed-off-by: A Ambrose <aambrose@...>

---

mama/c_cpp/src/cpp/MamaDictionary.cpp | 8 ++++----

mama/c_cpp/src/cpp/MamaMsgQual.cpp    | 4 +++-

mama/c_cpp/src/cpp/MamaSource.cpp     | 3 ++-

mama/c_cpp/src/cpp/MamaTransport.cpp  | 4 ++--

4 files changed, 11 insertions(+), 8 deletions(-)

 

diff --git a/mama/c_cpp/src/cpp/MamaDictionary.cpp b/mama/c_cpp/src/cpp/MamaDictionary.cpp

index 0471b90..6fa8fdb 100644

--- a/mama/c_cpp/src/cpp/MamaDictionary.cpp

+++ b/mama/c_cpp/src/cpp/MamaDictionary.cpp

@@ -387,20 +387,20 @@ DictionaryImpl::~DictionaryImpl (void)

     for (int i = 0; i <= getMaxFid(); i++)

     {

         mamaFieldDescriptor fd = 0;

-        mamaTryIgnoreNotFound (mamaDictionary_getFieldDescriptorByFid (

+        mamaDictionary_getFieldDescriptorByFid (

                 mDictionary,

                 &fd,

-                i));

+                i);

         if (fd)

         {

             void* closureData;

-            mamaTry (mamaFieldDescriptor_getClosure (fd, &closureData));

+            mamaFieldDescriptor_getClosure (fd, &closureData);

             MamaFieldDescriptor* cppFd = (MamaFieldDescriptor*)closureData;

             delete cppFd;

         }

     }

 

-    mamaTry (mamaDictionary_destroy (mDictionary));

+    mamaDictionary_destroy (mDictionary);

     mDictionary = 0;

}

 

diff --git a/mama/c_cpp/src/cpp/MamaMsgQual.cpp b/mama/c_cpp/src/cpp/MamaMsgQual.cpp

index 5217c10..8372cf4 100644

--- a/mama/c_cpp/src/cpp/MamaMsgQual.cpp

+++ b/mama/c_cpp/src/cpp/MamaMsgQual.cpp

@@ -50,7 +50,9 @@ namespace Wombat

         {

             delete myStrRep;

         }

-        mamaTry (mamaMsgQual_destroy (myMsgQual));

+

+        if (NULL != myMsgQual)

+            mamaMsgQual_destroy (myMsgQual);

     }

 

     MamaMsgQual& MamaMsgQual::operator= (const MamaMsgQual& rhs)

diff --git a/mama/c_cpp/src/cpp/MamaSource.cpp b/mama/c_cpp/src/cpp/MamaSource.cpp

index c5a5e6c..afbb305 100644

--- a/mama/c_cpp/src/cpp/MamaSource.cpp

+++ b/mama/c_cpp/src/cpp/MamaSource.cpp

@@ -148,7 +148,8 @@ namespace Wombat

 

     MamaSource::~MamaSource ()

     {

-        mamaTry (mamaSource_destroy (mySource));

+        if (NULL != mySource)

+            mamaSource_destroy (mySource);

 

         if (mySubs)

         {

diff --git a/mama/c_cpp/src/cpp/MamaTransport.cpp b/mama/c_cpp/src/cpp/MamaTransport.cpp

index a6823cd..259bfe1 100644

--- a/mama/c_cpp/src/cpp/MamaTransport.cpp

+++ b/mama/c_cpp/src/cpp/MamaTransport.cpp

@@ -319,9 +319,9 @@ namespace Wombat

                                    {

                                                    delete mPimpl->mCallback;

                                    }

-            if (mPimpl->mDeleteCTransport)

+            if (mPimpl->mDeleteCTransport && NULL != mTransport)

             {

-                mamaTry (mamaTransport_destroy (mTransport));

+                mamaTransport_destroy (mTransport);

             }

             delete mPimpl;

             mPimpl = NULL;

--

1.8.3.1

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.