Re: ​[PATCH 6.2.1] MAMA C++: Fixed memory leak in MamaMsgField


Frank Quinn <fquinn.ni@...>
 

Hi Victor,

Apologies - yes the website is out of date - I'll update it.


I did raise the PR on your request though:


And just merged into next so it will be included in the next release.

Cheers,
Frank


On Wed, Nov 8, 2017 at 1:39 PM, Victor Maleyev <imnotmindlin@...> wrote:
Hey Damian,

Could you apply the patch? I thought it's official way to contribute changes - it is documented on openmama.org -> Contribute.

08.11.2017, 14:51, "Damian Maguire" <dmaguire@...>:

Hey Victor,


In Github projects, forking is generally the best way to work with the project, and is the recommended approach for raising patches for OpenMAMA - you can actually see the forks used by the likes of myself, Frank and other contributors if you go looking.


Regarding some documentation, you can find a bunch in the 'Contributor Guides' section of the OpenMAMA GitHub page, with the 'Submission Process' page probably the most interesting for you: https://openmama.github.io/openmama_submission_process.html


If you still aren't comfortable with the approach once you've given it a try, or if you hit some difficulties, we can apply the patch for you, but I'd recommend you give it a go - it's a much nicer way of working with the project than sending patches around, and should let you use a bunch of GitHub's other functionality as well.


Any questions feel free to reach out to me.


Thanks,


Damian



DAMIAN MAGUIRE 

Senior Sales Engineer 

 

M. +44 783 584 4770 

 

Adelaide Exchange Building2nd Floor, 24-26 Adelaide StreetBelfast, BT2 8GD  

velatradingtech.com | @vela_tt





From: Victor Maleyev <imnotmindlin@...>
Sent: 08 November 2017 11:01
To: Frank Quinn
Cc: openmama-dev; Damian Maguire; frank@...
Subject: Re: [Openmama-dev] [PATCH 6.2.1] MAMA C++: Fixed memory leak in MamaMsgField
 
Hi Frank,

I don't know how to make pull requests without forking the project, that's why I sent the patch. Is it possible for you to apply it? Or is it any instruction on how to do pull requests?

08.11.2017, 02:41, "Frank Quinn" <fquinn.ni@...>:

Thanks Victor,

Yes I can see how that wouldn't have behaved as expected and fix looks sound. Are you going to raise a pull request against the "next" branch for this or do you want me to take it from here?

Cheers,
Frank


On Mon, 6 Nov 2017, 09:55 Victor Maleyev, <imnotmindlin@...> wrote:
Not sure if my previous mail reached the maillist. Adding list admins, sorry if this is inapropriate.
---
It is possible to reproduce memory leak using the following:

MamaMsgIterator i;
for(MamaMsgField field = msg.begin(i); ...; field =  *++i) {
    field.getVectorMsg(...);
}

Note that field is not reference but object.

When calling getVectorMsg() the array of pointers (mLastVectorMsg) is allocated by malloc but when we assign a new value to the field (field = *++i) the allocated array becomes unreachable and can't be deleted. Overloaded assignment operator calling clear before assignment can solve this.
Signed-off-by: Victor Maleyev <imnotmindlin@...>

From c036b0726464916b2e49d6b1297a2a82404c0359 Mon Sep 17 00:00:00 2001
From: Victor Maleyev <imnotmindlin@...>
Date: Fri, 3 Nov 2017 00:14:05 +0300
Subject: [PATCH] Fixed memory leak in MamaMsgField

Signed-off-by: Victor Maleyev <imnotmindlin@...>
---
 mama/c_cpp/src/cpp/MamaMsgField.cpp | 15 +++++++++++++++
 mama/c_cpp/src/cpp/mama/MamaMsgField.h | 6 ++++++
 2 files changed, 21 insertions(+)

diff --git a/mama/c_cpp/src/cpp/MamaMsgField.cpp b/mama/c_cpp/src/cpp/MamaMsgField.cpp
index f2f287c..2cf1270 100644
--- a/mama/c_cpp/src/cpp/MamaMsgField.cpp
+++ b/mama/c_cpp/src/cpp/MamaMsgField.cpp
@@ -47,6 +47,21 @@ namespace Wombat
     {
     }

+ MamaMsgField::MamaMsgField (const MamaMsgField& field)
+ : mField (field.mField)
+ , mFieldDesc (NULL)
+ , mLastVectorMsg (NULL)
+ , mLastVectorMsgLen (0)
+ {
+ }
+
+ MamaMsgField& MamaMsgField::operator= (const MamaMsgField& field)
+ {
+ clear();
+ mField = field.mField;
+ return *this;
+ }
+
     void MamaMsgField::clear ()
     {
         if (mFieldDesc)
diff --git a/mama/c_cpp/src/cpp/mama/MamaMsgField.h b/mama/c_cpp/src/cpp/mama/MamaMsgField.h
index b9b9e73..d8f45b1 100644
--- a/mama/c_cpp/src/cpp/mama/MamaMsgField.h
+++ b/mama/c_cpp/src/cpp/mama/MamaMsgField.h
@@ -50,6 +50,12 @@ namespace Wombat
         MamaMsgField (
             mamaMsgField field);

+ MamaMsgField (
+ const MamaMsgField& field);
+
+ MamaMsgField& operator= (
+ const MamaMsgField& field);
+
         /**
          * Clear the field.
          */
--
2.13.3
-------- Конец пересылаемого сообщения --------_______________________________________________
Openmama-dev mailing list
Openmama-dev@....org
https://lists.openmama.org/mailman/listinfo/openmama-dev




The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to this message and deleting it from your computer. Thank you. Vela Trading Technologies LLC




Join Openmama-dev@lists.openmama.org to automatically receive all group messages.