bugGNU Octave - Bugs: bug #40228, Memory leak in...

 
 

bug #40228: Memory leak in octave_base64_(encode|decode)

Submitter:  Rik <rik5>
Submitted:  Thu 10 Oct 2013 02:21:14 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  jwe
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 10 Oct 2013 03:09:04 AM UTC, comment #4: 

Yup, it's gone now.  And aren't you burning the nearly midnight oil on the East Coast?

Rik <rik5>
Group administrator
Thu 10 Oct 2013 02:55:45 AM UTC, comment #3: 

I checked in the following changeset.  It seems to work for me.  If you can verify that it works, please close this report.

http://hg.savannah.gnu.org/hgweb/octave/rev/d41c8f96ed06

John W. Eaton <jwe>
Group administrator
Thu 10 Oct 2013 02:46:19 AM UTC, comment #2: 

I'm looking at these now.

John W. Eaton <jwe>
Group administrator
Thu 10 Oct 2013 02:24:20 AM UTC, comment #1: 

And there is a second leak in the decode function.


==16089== 1,608 bytes in 2 blocks are definitely lost in loss record 1,067 of 1,172
==16089==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==16089==    by 0x6F3BBD6: base64_decode_alloc_ctx (base64.c:559)
==16089==    by 0x6F09E27: octave_base64_decode(std::string const&) (oct-base64.cc:66)
==16089==    by 0x59461EE: Fbase64_decode(octave_value_list const&, int) (data.cc:7443)
==16089==    by 0x57673B0: octave_builtin::do_multi_index_op(int, octave_value_list const&, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:131)
==16089==    by 0x5767057: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:64)
==16089==    by 0x5766F45: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov-builtin.cc:47)
==16089==    by 0x5767EA6: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&) (ov-builtin.h:62)
==16089==    by 0x580DB74: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov.cc:1267)
==16089==    by 0x580DC6F: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov.cc:1280)
==16089==    by 0x587696E: tree_index_expression::rvalue(int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (pt-idx.cc:414)
==16089==    by 0x58760C6: tree_index_expression::rvalue(int) (pt-idx.cc:284)
==16089==    by 0x5876BC5: tree_index_expression::rvalue1(int) (pt-idx.cc:425)
==16089==    by 0x5864DE7: tree_simple_assignment::rvalue1(int) (pt-assign.cc:84)
==16089==    by 0x587016A: tree_evaluator::visit_statement(tree_statement&) (pt-eval.cc:747)
==16089==    by 0x5890AD3: tree_statement::accept(tree_walker&) (pt-stmt.cc:178)
==16089==    by 0x58703D5: tree_evaluator::visit_statement_list(tree_statement_list&) (pt-eval.cc:797)
==16089==    by 0x58910F3: tree_statement_list::accept(tree_walker&) (pt-stmt.cc:291)
==16089==    by 0x58033B6: octave_user_function::do_multi_index_op(int, octave_value_list const&, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-usr-fcn.cc:588)
==16089==    by 0x5802CA5: octave_user_function::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-usr-fcn.cc:437)
==16089==    by 0x580DC4F: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov.cc:1278)
==16089==    by 0x587696E: tree_index_expression::rvalue(int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (pt-idx.cc:414)
==16089==    by 0x586562C: tree_multi_assignment::rvalue(int) (pt-assign.cc:230)
==16089==    by 0x58B883E: eval_string(std::string const&, bool, int&, int) (oct-parse.yy:4126)
==16089==    by 0x58B8B9E: eval_string(octave_value const&, bool, int&, int) (oct-parse.yy:4179)
==16089==    by 0x58B8D01: Feval(octave_value_list const&, int) (oct-parse.yy:4243)
==16089==    by 0x57673B0: octave_builtin::do_multi_index_op(int, octave_value_list const&, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:131)
==16089==    by 0x5767057: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:64)
==16089==    by 0x5766F45: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov-builtin.cc:47)
==16089==    by 0x580DBC7: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov.cc:1269)
==16089==    by 0x580DC6F: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov.cc:1280)
==16089==    by 0x587696E: tree_index_expression::rvalue(int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (pt-idx.cc:414)
==16089==    by 0x58760C6: tree_index_expression::rvalue(int) (pt-idx.cc:284)
==16089==    by 0x5876BC5: tree_index_expression::rvalue1(int) (pt-idx.cc:425)
==16089==    by 0x587016A: tree_evaluator::visit_statement(tree_statement&) (pt-eval.cc:747)
==16089==    by 0x5890AD3: tree_statement::accept(tree_walker&) (pt-stmt.cc:178)
==16089==    by 0x58703D5: tree_evaluator::visit_statement_list(tree_statement_list&) (pt-eval.cc:797)
==16089==    by 0x58910F3: tree_statement_list::accept(tree_walker&) (pt-stmt.cc:291)
==16089==    by 0x586FBE4: tree_evaluator::visit_if_command_list(tree_if_command_list&) (pt-eval.cc:588)
==16089==    by 0x588E80F: tree_if_command_list::accept(tree_walker&) (pt-select.cc:83)
==16089==    by 0x586FA77: tree_evaluator::visit_if_command(tree_if_command&) (pt-eval.cc:563)
==16089==    by 0x588EA2B: tree_if_command::accept(tree_walker&) (pt-select.cc:108)
==16089==    by 0x5870083: tree_evaluator::visit_statement(tree_statement&) (pt-eval.cc:721)
==16089==    by 0x5890AD3: tree_statement::accept(tree_walker&) (pt-stmt.cc:178)
==16089==    by 0x58703D5: tree_evaluator::visit_statement_list(tree_statement_list&) (pt-eval.cc:797)
==16089==    by 0x58910F3: tree_statement_list::accept(tree_walker&) (pt-stmt.cc:291)
==16089==    by 0x58707C1: tree_evaluator::visit_try_catch_command(tree_try_catch_command&) (pt-eval.cc:910)
==16089==    by 0x587221B: tree_try_catch_command::accept(tree_walker&) (pt-except.cc:72)
==16089==    by 0x5870083: tree_evaluator::visit_statement(tree_statement&) (pt-eval.cc:721)
==16089==    by 0x5890AD3: tree_statement::accept(tree_walker&) (pt-stmt.cc:178)


Rik <rik5>
Group administrator
Thu 10 Oct 2013 02:21:14 AM UTC, original submission:  

I ran the test suite under valgrind and this leak showed up.  base64.c is from gnulib, so Octave is probably not managing the interaction between C++ (Octave) and C (gnulib) correctly.


==16089== 2,138 bytes in 2 blocks are definitely lost in loss record 1,096 of 1,172
==16089==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==16089==    by 0x6F3B4E9: base64_encode_alloc (base64.c:136)
==16089==    by 0x6F09D6E: octave_base64_encode(char const*, unsigned long, char**) (oct-base64.cc:39)
==16089==    by 0x5945DD8: Fbase64_encode(octave_value_list const&, int) (data.cc:7384)
==16089==    by 0x57673B0: octave_builtin::do_multi_index_op(int, octave_value_list const&, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:131)
==16089==    by 0x5767057: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:64)
==16089==    by 0x5766F45: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov-builtin.cc:47)
==16089==    by 0x5767EA6: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&) (ov-builtin.h:62)
==16089==    by 0x580DB74: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov.cc:1267)
==16089==    by 0x580DC6F: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov.cc:1280)
==16089==    by 0x587696E: tree_index_expression::rvalue(int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (pt-idx.cc:414)
==16089==    by 0x58760C6: tree_index_expression::rvalue(int) (pt-idx.cc:284)
==16089==    by 0x5876BC5: tree_index_expression::rvalue1(int) (pt-idx.cc:425)
==16089==    by 0x5862A99: tree_argument_list::convert_to_const_vector(octave_value const*) (pt-arg-list.cc:224)
==16089==    by 0x58762CC: tree_index_expression::rvalue(int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (pt-idx.cc:315)
==16089==    by 0x58760C6: tree_index_expression::rvalue(int) (pt-idx.cc:284)
==16089==    by 0x5876BC5: tree_index_expression::rvalue1(int) (pt-idx.cc:425)
==16089==    by 0x5864DE7: tree_simple_assignment::rvalue1(int) (pt-assign.cc:84)
==16089==    by 0x587016A: tree_evaluator::visit_statement(tree_statement&) (pt-eval.cc:747)
==16089==    by 0x5890AD3: tree_statement::accept(tree_walker&) (pt-stmt.cc:178)
==16089==    by 0x58703D5: tree_evaluator::visit_statement_list(tree_statement_list&) (pt-eval.cc:797)
==16089==    by 0x58910F3: tree_statement_list::accept(tree_walker&) (pt-stmt.cc:291)
==16089==    by 0x58033B6: octave_user_function::do_multi_index_op(int, octave_value_list const&, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-usr-fcn.cc:588)
==16089==    by 0x5802CA5: octave_user_function::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-usr-fcn.cc:437)
==16089==    by 0x580DC4F: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov.cc:1278)
==16089==    by 0x587696E: tree_index_expression::rvalue(int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (pt-idx.cc:414)
==16089==    by 0x586562C: tree_multi_assignment::rvalue(int) (pt-assign.cc:230)
==16089==    by 0x58B883E: eval_string(std::string const&, bool, int&, int) (oct-parse.yy:4126)
==16089==    by 0x58B8B9E: eval_string(octave_value const&, bool, int&, int) (oct-parse.yy:4179)
==16089==    by 0x58B8D01: Feval(octave_value_list const&, int) (oct-parse.yy:4243)
==16089==    by 0x57673B0: octave_builtin::do_multi_index_op(int, octave_value_list const&, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:131)
==16089==    by 0x5767057: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov-builtin.cc:64)
==16089==    by 0x5766F45: octave_builtin::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov-builtin.cc:47)
==16089==    by 0x580DBC7: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int) (ov.cc:1269)
==16089==    by 0x580DC6F: octave_value::subsref(std::string const&, std::list<octave_value_list, std::allocator<octave_value_list> > const&, int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (ov.cc:1280)
==16089==    by 0x587696E: tree_index_expression::rvalue(int, std::list<octave_lvalue, std::allocator<octave_lvalue> > const*) (pt-idx.cc:414)
==16089==    by 0x58760C6: tree_index_expression::rvalue(int) (pt-idx.cc:284)
==16089==    by 0x5876BC5: tree_index_expression::rvalue1(int) (pt-idx.cc:425)
==16089==    by 0x587016A: tree_evaluator::visit_statement(tree_statement&) (pt-eval.cc:747)
==16089==    by 0x5890AD3: tree_statement::accept(tree_walker&) (pt-stmt.cc:178)
==16089==    by 0x58703D5: tree_evaluator::visit_statement_list(tree_statement_list&) (pt-eval.cc:797)
==16089==    by 0x58910F3: tree_statement_list::accept(tree_walker&) (pt-stmt.cc:291)
==16089==    by 0x586FBE4: tree_evaluator::visit_if_command_list(tree_if_command_list&) (pt-eval.cc:588)
==16089==    by 0x588E80F: tree_if_command_list::accept(tree_walker&) (pt-select.cc:83)
==16089==    by 0x586FA77: tree_evaluator::visit_if_command(tree_if_command&) (pt-eval.cc:563)
==16089==    by 0x588EA2B: tree_if_command::accept(tree_walker&) (pt-select.cc:108)
==16089==    by 0x5870083: tree_evaluator::visit_statement(tree_statement&) (pt-eval.cc:721)
==16089==    by 0x5890AD3: tree_statement::accept(tree_walker&) (pt-stmt.cc:178)
==16089==    by 0x58703D5: tree_evaluator::visit_statement_list(tree_statement_list&) (pt-eval.cc:797)
==16089==    by 0x58910F3: tree_statement_list::accept(tree_walker&) (pt-stmt.cc:291)



Rik <rik5>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-10 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2013-10-10 jwe StatusNone Ready For Test
    2013-10-10 jwe Assigned toNone jwe
    2013-10-10 rik5 SummaryMemory leak in octave_base64_encode Memory leak in octave_base64_(encode|decode)

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code