← Back to team overview

ffc team mailing list archive

Re: deleting ufc_form

 

On Mon, Nov 24, 2008 at 10:15:48PM +0100, Johan Hake wrote:
> On Monday 24 November 2008 22:02:43 Anders Logg wrote:
> > On Mon, Nov 24, 2008 at 09:39:45PM +0100, Johan Hake wrote:
> > > Hello!
> > >
> > > While working on the python interface of dolfin I come over a memory
> > > corruption in the dolfin::Form destructor. While ffc -ldolfin produce
> > > code to instantiate a dolfin::Form it does not take care of deleting the
> > > ufc_form.
> > >
> > > In the destrutor of the base class Form there is a
> > >
> > >   delete _ufc_form;
> > >
> > > I do not know if this while prevent any memory leak from the ffc produced
> > > code, e.g., if the base class destructor is not calle or something, but
> > > that line _will_ corrupt any try to instantiate a dolfin::Form directly
> > > using an ufc_form, which we have to do in PyDOLFIN.
> > >
> > > My suggestion is to remove the above mentioned line from dolfin::~Form(),
> > > which I have done locally, and add the same line in the destructor of the
> > > derived class produced by ffc.
> > >
> > > Any comment?
> > >
> > > Johan
> >
> > Sounds good. Patches welcome. Will get started on applying your other
> > patches.
> 
> Well, I am not so into the code generation part of ffc, so I would have hoped 
> you could have a look at it ;)

Sure, it's an easy fix (in dolfinformat.py). I will fix it as soon as
I get a chance.

> Btw, why isn't _ufc_form stored as a shared_ptr? It would make it a bit 
> easier. 

It wasn't needed at the time. I'll think about making it a shared
pointer.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References