[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests
From: |
John W. Eaton |
Subject: |
[Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests |
Date: |
Sat, 4 Dec 2021 11:05:18 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 |
Follow-up Comment #12, bug #61472 (project octave):
I would prefer to avoid adding function pointers to the Array classes.
Instead, I think we should extend them with template parameters that allow for
custom allocators in the same way that the standard library containers do.
I'm attaching two changesets for discussion.
The first adds a template parameter to the Array class to allow allow custom
allocators and uses the allocator class to manage storage allocation for the
ArrayRep object. In this change, the default allocator is std::allocator<T>
so it will work with C++11. But if you attempt to define a custom allocator
for the MEX objects using this interface, you'll run into trouble because
Array<double,std::allocator<double>> is a different type from
Array<double,my_special_allocator> so storing the Array with the custom
allocator in an octave_value object requires modifying the octave_value class
to accept a new type. We definitely don't want that.
The second change changes the default allocator for the Array class to be
std::pmr::polymorphic_allocator<T> and modifies the Array<T,Alloc>::Array(T
*data, size_t n) constructor to accept a allocator object. With this
interface, we don't end up with different types when using custom allocators
so no changes are required for the octave_value container. However, the
change requires C++17 so I made the change conditional. If you don't have
C++17 features, you'll continue to mix malloc/delete.
Note that these changes don't add data to the Array classes. The allocator
objects don't have data, they just provide functions.
Things that remain to be done are
* Add allocators template parameters to other containers in Octave like
Sparse<T>
* Add allocator parameters to other constructors
* Move the definition of the custom MEX allocator to a separate file.
To try the two attached changesets, you'll need to be at revision
http://hg.savannah.gnu.org/hgweb/octave/rev/e38202d3628d or newer
(file #52426, file #52427)
_______________________________________________________
Additional Item Attachment:
File name: cset-1-array-alloc.txt Size:57 KB
<https://file.savannah.gnu.org/file/cset-1-array-alloc.txt?file_id=52426>
File name: cset-2-custom-mex-alloc.txt Size:5 KB
<https://file.savannah.gnu.org/file/cset-2-custom-mex-alloc.txt?file_id=52427>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61472>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Markus Mützel, 2021/12/02
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Arun Giridhar, 2021/12/02
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, John W. Eaton, 2021/12/02
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, anonymous, 2021/12/02
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, anonymous, 2021/12/02
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, anonymous, 2021/12/02
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Arun Giridhar, 2021/12/03
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests,
John W. Eaton <=
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Arun Giridhar, 2021/12/04
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, anonymous, 2021/12/04
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, John W. Eaton, 2021/12/04
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Markus Mützel, 2021/12/05
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Arun Giridhar, 2021/12/05
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Markus Mützel, 2021/12/05
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, John W. Eaton, 2021/12/05
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, John W. Eaton, 2021/12/05
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Markus Mützel, 2021/12/05
- [Octave-bug-tracker] [bug #61472] AddressSanitizer crash in MEX tests, Arun Giridhar, 2021/12/05