[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #52083] Memory leak during error when instanti
From: |
Piotr Held |
Subject: |
[Octave-bug-tracker] [bug #52083] Memory leak during error when instantiating child of sealed class |
Date: |
Thu, 21 Sep 2017 15:03:10 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?52083>
Summary: Memory leak during error when instantiating child of
sealed class
Project: GNU Octave
Submitted by: jsoh425
Submitted on: Thu 21 Sep 2017 07:03:08 PM UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Other
Status: None
Assigned to: None
Originator Name: Piotr Held
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
The problem even though small highlights a future problem/opportunity for
attribute validation.
The leak occurs when throwing an exception inside cdef_class::make_meta_class
<http://hg.savannah.gnu.org/hgweb/octave/file/dbbc7e5e2294/libinterp/octave-value/ov-classdef.cc>,
and it just so happens that the only error inside that method is when creating
a meta class for a child of a Sealed class. After the error the tree_classdef
object associated with the child class is never destroyed.
My solution to the problem is basically to catch the error, call the
destructor and rethrow the error. With the simple code (included in
memory_leak_patch.diff):
try
{
fcn_ptr
= parser.m_classdef_object->make_meta_class(interp,
is_at_folder);
}
catch (const octave::execution_exception& e)
{
delete (parser.m_classdef_object);
throw e;
}
This code would go to parse_fcn_file
<http://hg.savannah.gnu.org/hgweb/octave/file/dbbc7e5e2294/libinterp/parse-tree/oct-parse.in.yy#l4527>.
I also believe that attribute validation, which at this point basically
doesn't exist, should go inside cdef_class::make_meta_class
<http://hg.savannah.gnu.org/hgweb/octave/file/dbbc7e5e2294/libinterp/octave-value/ov-classdef.cc>.
This is because attributes can be assigned expressions and, therefore, these
expressions need to be evaluated somewhere. If we evaluate them right when
parsing the attribute itself we can run into recursion problems which I
described in Bug #51377 Comment5
<https://savannah.gnu.org/bugs/?func=detailitem&item_id=51377#comment5> and
also documented in documentation.diff.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Thu 21 Sep 2017 07:03:08 PM UTC Name: memory_leak_patch.diff Size:
1KiB By: jsoh425
<http://savannah.gnu.org/bugs/download.php?file_id=41861>
-------------------------------------------------------
Date: Thu 21 Sep 2017 07:03:08 PM UTC Name: documentation.diff Size: 2KiB
By: jsoh425
<http://savannah.gnu.org/bugs/download.php?file_id=41862>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?52083>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #52083] Memory leak during error when instantiating child of sealed class,
Piotr Held <=