[Root Pointer] Deterministic C++ memory manager (update)
Greetings, I wanted to give an update to the community regarding the memory manager I wrote called: Root Pointer. I now have a working template to solve all memory leaks in C++ and C but both requires some meta data generator. The code can be found here; it is working but not polished: https://github.com/philippeb8/root_ptr In this code we can find: - node_ptr: main class of the smart pointer / memory manager. - root_ptr: generic derived class that includes an "iterator" and a pointer to the name of the instance (for debugging purposes). Also I commented some code that logs the exact location of the memory leak. Furthermore I would like to bring some observations that I found in the C and the C++ language: - Pointers and iterators are not the same; i.e. pointers should point to allocated blocks only and shouldn't have arithmetic operators while iterators shouldn't be used to deallocate anything. - C pointers can only point to dynamic arrays (size known at run-time). - C++ pointers can point to both inherited objects and static arrays (size known at compile-time). This creates a problem (see attached: array_inherited_pointer.cpp). - std::array<T> should have constructors with T objects that have no default constructor. Lastly, before I submit anything, I will have to propose a way to apply a template function to all non-static member variables of a class. This will require implicit meta data generation. This idea is not new as other libraries such as Qt is based on meta data and they certainly could make us of this. For the moment I have a parser that does the job correctly by specializing a boost::proxy() template function but eventually this will have to be integrated into the standards. Hopefully this is an important milestone! Regards, Phil Bouchard www.fornux.com
On Tue, Nov 14, 2017 at 9:40 PM, Phil Bouchard via Boost
Greetings,
I wanted to give an update to the community regarding the memory manager I wrote called: Root Pointer.
Just to let you know, that I've seen your message. But, right now library authors are in the middle of preparing to ship Boost 1.66.0 (it is currently in beta) so you might not see activity on this thread until after the release. Hang in there! Thanks
On 11/18/2017 09:10 PM, Vinnie Falco via Boost wrote:
On Tue, Nov 14, 2017 at 9:40 PM, Phil Bouchard via Boost
wrote: Greetings,
I wanted to give an update to the community regarding the memory manager I wrote called: Root Pointer.
Just to let you know, that I've seen your message. But, right now library authors are in the middle of preparing to ship Boost 1.66.0 (it is currently in beta) so you might not see activity on this thread until after the release. Hang in there!
Thanks
That's fine; I'm discussing it with the ISO C++ committee and I wanted to keep Boost in sync. Like I was saying before I'll need to change the C++ standards before its implementation can be part of the Boost library (reverse flow). For the moment you are welcome to take a look at what my [commercial] parser does when it converts a C app into C++ while injecting Root.Ptr. You'll notice node_proxy needs to be instantiated at each new scope and references to these proxies are passed to each function and base class. Later, -Phil
On 11/15/2017 12:40 AM, Phil Bouchard via Boost wrote:
Greetings,
I wanted to give an update to the community regarding the memory manager I wrote called: Root Pointer.
I now have a working template to solve all memory leaks in C++ and C but both requires some meta data generator. The code can be found here; it is working but not polished: https://github.com/philippeb8/root_ptr
In this code we can find:
- node_ptr: main class of the smart pointer / memory manager. - root_ptr: generic derived class that includes an "iterator" and a pointer to the name of the instance (for debugging purposes).
Also I commented some code that logs the exact location of the memory leak.
Furthermore I would like to bring some observations that I found in the C and the C++ language:
- Pointers and iterators are not the same; i.e. pointers should point to allocated blocks only and shouldn't have arithmetic operators while iterators shouldn't be used to deallocate anything. - C pointers can only point to dynamic arrays (size known at run-time). - C++ pointers can point to both inherited objects and static arrays (size known at compile-time). This creates a problem (see attached: array_inherited_pointer.cpp). - std::array<T> should have constructors with T objects that have no default constructor.
Lastly, before I submit anything, I will have to propose a way to apply a template function to all non-static member variables of a class. This will require implicit meta data generation. This idea is not new as other libraries such as Qt is based on meta data and they certainly could make us of this. For the moment I have a parser that does the job correctly by specializing a boost::proxy() template function but eventually this will have to be integrated into the standards.
Hopefully this is an important milestone!
Regards, Phil Bouchard www.fornux.com
Here is yet another important update:
https://github.com/philippeb8/root_ptr/tree/master/include/boost/smart_ptr
I've been testing Fornux C Leak Detector (modified Clang which uses
Root.Ptr) with a modified libarchive 3.2.2:
https://github.com/philippeb8/libarchive/commit/5858b5c047301123ffdf05f247f7...
And I've got the following diagnosis:
[2017-12-24 16:20:04.536311] [0x00007fd0b34f3fc0] [info] <cycle>: 0#
archive_read_open_filenames(boost::node_proxy&,
boost::root_ptr
, unsigned long) at /home/philippeb8/devel/1/libarchive-3.2.2/libarchive/archive_read_open_filename.c:164
[2017-12-24 16:20:04.614519] [0x00007fd0b34f3fc0] [info] "p": 0#
gnu_clear_sparse_list(boost::node_proxy&,
boost::root_ptr
) at /home/philippeb8/devel/1/libarchive-.2.2/libarchive/archive_read_support_format_tar.c:237
[2017-12-24 16:20:04.734981] [0x00007fd0b34f3fc0] [info] "client_buff": 0# ~archive_read_filter at /home/philippeb8/devel/1/libarchive-3.2.2/libarchive/archive_read_private.h:82 "p" and "tar" being explicitly deleted in the code leaves us with with "client_buff" that leaks in this version of libarchive (3.2.2). This proves Root.Ptr works with commercial software and doesn't slow down the final app (in contrast with Herb Sutter's deferred_ptr, Valgrind, Parasoft Insure++ and Rationale Purify). On another note, it would be great to throw an exception on segmentation faults. This way it would be possible to automatically generate a stack dump using Fornux C Leak Detector because it can add the necessary information on the stack. Merry Christmas and Happy New Year! -Phil www.fornux.com
On 12/24/2017 05:29 PM, Phil Bouchard via Boost wrote:
Here is yet another important update: https://github.com/philippeb8/root_ptr/tree/master/include/boost/smart_ptr
I've been testing Fornux C Leak Detector (modified Clang which uses Root.Ptr) with a modified libarchive 3.2.2: https://github.com/philippeb8/libarchive/commit/5858b5c047301123ffdf05f247f7...
For the starters, I've updated the simple example (I will have to update downcasting again): https://github.com/philippeb8/root_ptr/blob/master/example/root_ptr_example1... So once again this solution is divided into 3 major steps: 1) Commercial Clang-based parser that generates all the necessary code for C (already completed) and C++ applications later on. 2) Integration into Boost the day Boost will support generation of metadata. 3) Attempt to promote all this to the C++ ISO Standards (it will have to support metadata, implicit parameters and implicit compound statement instances). Any help is always appreciated to polish the Open Source counterpart. *** Warning: *** The code uses: - "reinterpret_cast" because the C++ language is not perfect and I have no other choice. I will try again later to sort it out. - "mutable" because I need to be able to change r-values. Sincerely, Phil Bouchard www.fornux.com
On 01/25/2018 04:04 PM, Phil Bouchard via Boost wrote:
On 12/24/2017 05:29 PM, Phil Bouchard via Boost wrote:
Here is yet another important update: https://github.com/philippeb8/root_ptr/tree/master/include/boost/smart_ptr
I've been testing Fornux C Leak Detector (modified Clang which uses Root.Ptr) with a modified libarchive 3.2.2: https://github.com/philippeb8/libarchive/commit/5858b5c047301123ffdf05f247f7...
For the starters, I've updated the simple example (I will have to update downcasting again): https://github.com/philippeb8/root_ptr/blob/master/example/root_ptr_example1...
Ok downcasting is fine now and it can be used as such: cout << "Downcasting:" << endl; { node_proxy x; node_ptr<C> p = dynamic_pointer_cast<C>(make_node<B>(x)); cout << p.get() << endl; } cout << endl; Sincerely, Phil Bouchard www.fornux.com
participants (2)
-
Phil Bouchard
-
Vinnie Falco