[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61813] memory management bug when calling MEX
From: |
Sébastien Villemot |
Subject: |
[Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output |
Date: |
Thu, 13 Jan 2022 10:31:37 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0 |
URL:
<https://savannah.gnu.org/bugs/?61813>
Summary: memory management bug when calling MEX that returns
an output
Project: GNU Octave
Submitted by: svillemot
Submitted on: jeu. 13 janv. 2022 15:31:35 UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Regression
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: 7.0.90
Discussion Lock: Any
Operating System: Any
_______________________________________________________
Details:
Hi,
I attach a very basic MEX file that triggers a memory management bug
(incorrect memory free). This is a regression in 7.0.90.
The source has to be compiled with:
mkoctfile -mex mexmembug.c
Then, launch Octave within Valgrind:
valgrind octave-cli
When the Octave prompt appears, run:
n = mexmembug;
Then Valgrind prints the following:
==3733875== Mismatched free() / delete / delete []
==3733875== at 0x484299B: operator delete(void*, unsigned long)
(vg_replace_malloc.c:935)
==3733875== by 0x50A5F28:
__gnu_cxx::new_allocator<double>::deallocate(double*, unsigned long)
(new_allocator.h:145)
==3733875== by 0x50A5E25: std::allocator_traits<std::allocator<double>
>::deallocate(std::allocator<double>&, double*, unsigned long)
(alloc_traits.h:496)
==3733875== by 0x50A5CC1: Array<double, std::allocator<double>
>::ArrayRep::deallocate(double*, unsigned long) (Array.h:207)
==3733875== by 0x50A5BB8: Array<double, std::allocator<double>
>::ArrayRep::~ArrayRep() (Array.h:187)
==3733875== by 0x50A59C7: Array<double, std::allocator<double> >::~Array()
(Array.h:356)
==3733875== by 0x5AF2580: octave_value
mxArray_base_full::fp_to_ov<double>(dim_vector const&) const (mex.cc:2177)
==3733875== by 0x5AEDE06: mxArray_base_full::as_octave_value() const
(mex.cc:2084)
==3733875== by 0x5AEED5D: mxArray_separate_full::as_octave_value() const
(mex.cc:2411)
==3733875== by 0x5AE1FDD: mxArray::as_octave_value() const (mex.cc:3242)
==3733875== by 0x5AE1F18: mxArray::as_octave_value(mxArray const*, bool)
(mex.cc:3236)
==3733875== by 0x5AE4CAB: call_mex(octave_mex_function&, octave_value_list
const&, int) (mex.cc:4785)
==3733875== Address 0x4705de10 is 0 bytes inside a block of size 8 alloc'd
==3733875== at 0x483F7B5: malloc (vg_replace_malloc.c:381)
==3733875== by 0x5AE1617: xmalloc(unsigned long) (mex.cc:270)
==3733875== by 0x5AF1769: mex::malloc_unmarked(unsigned long)
(mex.cc:3414)
==3733875== by 0x5AF182A: mex::calloc_unmarked(unsigned long, unsigned
long) (mex.cc:3441)
==3733875== by 0x5AE2713: mxArray::calloc(unsigned long, unsigned long)
(mex.cc:3686)
==3733875== by 0x5AED2C5: mxArray_base_full::mxArray_base_full(bool,
mxClassID, double) (mex.cc:1653)
==3733875== by 0x5AEE65E:
mxArray_separate_full::mxArray_separate_full(mxClassID, double) (mex.cc:2321)
==3733875== by 0x5AE22F1: mxArray::create_rep(bool, mxClassID, double)
(mex.cc:3287)
==3733875== by 0x5AE1949: mxArray::mxArray(bool, mxClassID, double)
(mex.cc:3164)
==3733875== by 0x5AE304C: mxCreateDoubleScalar (mex.cc:3895)
==3733875== by 0x709B135: mexFunction (mexmembug.c:10)
==3733875== by 0x5AE4C0A: call_mex(octave_mex_function&, octave_value_list
const&, int) (mex.cc:4769)
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: jeu. 13 janv. 2022 15:31:35 UTC Name: mexmembug.c Size: 254o By:
svillemot
<http://savannah.gnu.org/bugs/download.php?file_id=52659>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61813>
_______________________________________________
Message posté via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output,
Sébastien Villemot <=
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, Sébastien Villemot, 2022/01/13
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, Sébastien Villemot, 2022/01/13
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, Markus Mützel, 2022/01/13
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, Sébastien Villemot, 2022/01/13
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, John W. Eaton, 2022/01/13
- [Octave-bug-tracker] [bug #61813] memory management bug when calling MEX that returns an output, John W. Eaton, 2022/01/17