[mlpack-git] [mlpack] removing global dependency on cli deleter (#521)

Joseph Mariadassou notifications at github.com
Sat Feb 13 01:02:20 EST 2016


Looks like a case of accessing a deleted object. The order of destruction
of static objects cannot be predicted unless they are defined in the same
translation unit. in which case the objects are destroyed in the reverse
order.
Google "c++ order of destruction static objects" to see what I mean.
"The static objects are destructed in the reverse order of construction.
And the order of construction is very hard to control. The only thing you
can be sure of is that two objects defined in the same compilation unit
will be constructed in the order of definition. Anything else is more or
less random." (from
http://stackoverflow.com/questions/469597/destruction-order-of-static-objects-in-c
)
Hence you need to declare the static CLIDeleter in log.cpp after Log::Fatal.
I would prefer to get rid of CLIDeleter. My earlier suggestion should also
work because GetSingleton will be called inside main of after main is
launched by which time the Log objects would have been created.



On Sat, Feb 13, 2016 at 3:04 AM, Ryan Curtin <notifications at github.com>
wrote:

> valgrind shows some invalid accesses too:
>
> [DEBUG] Compiled with debugging symbols.
> [WARN ] Neither --neighbors_file nor --distances_file is specified, so the nearest neighbor search results will not be saved!
> [INFO ] Loading 'test_data_3_1000.csv' as CSV data.  Size is 3 x 1000.
> [INFO ] Loaded reference data from 'test_data_3_1000.csv' (3 x 1000).
> [INFO ] Building reference tree...
> [INFO ] Tree built.
> [INFO ] Searching for 3 nearest neighbors with dual-tree kd-tree search...
> [INFO ] 18080 node combinations were scored.
> [INFO ] 43890 base cases were calculated.
> [INFO ] Search complete.
> ==24595== Invalid read of size 1
> ==24595==    at 0x71562BA: _IO_file_xsputn@@GLIBC_2.2.5 (in /lib/x86_64-linux-gnu/libc-2.21.so)
> ==24595==    by 0x714C3D8: fwrite (in /lib/x86_64-linux-gnu/libc-2.21.so)
> ==24595==    by 0x651747D: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
> ==24595==    by 0x8589D9: mlpack::util::PrefixedOutStream::PrefixIfNeeded() (prefixedoutstream_impl.hpp:106)
> ==24595==    by 0x537428B: void mlpack::util::PrefixedOutStream::BaseLogic<std::ostream& (*)(std::ostream&)>(std::ostream& (* const&)(std::ostream&)) (prefixedoutstream_impl.hpp:34)
> ==24595==    by 0x5370F0C: mlpack::util::PrefixedOutStream::operator<<(std::ostream& (*)(std::ostream&)) (prefixedoutstream.cpp:112)
> ==24595==    by 0x535A98E: mlpack::CLI::~CLI() (cli.cpp:71)
> ==24595==    by 0x535B6B8: mlpack::CLI::Destroy() (cli.cpp:249)
> ==24595==    by 0x536FFD4: mlpack::util::CLIDeleter::~CLIDeleter() (cli_deleter.cpp:31)
> ==24595==    by 0x711919E: __cxa_finalize (in /lib/x86_64-linux-gnu/libc-2.21.so)
> ==24595==    by 0x52F1EA2: ??? (in /home/ryan/src/mlpack-tsp/build/lib/libmlpack.so.2.0)
> ==24595==    by 0x400F876: _dl_fini (in /lib/x86_64-linux-gnu/ld-2.21.so)
> ==24595==  Address 0x92d8e92 is 18 bytes inside a block of size 20 free'd
> ==24595==    at 0x4C2B2CB: operator delete(void*) (vg_replace_malloc.c:575)
> ==24595==    by 0x5370747: mlpack::util::PrefixedOutStream::~PrefixedOutStream() (prefixedoutstream.hpp:52)
> ==24595==    by 0x711919E: __cxa_finalize (in /lib/x86_64-linux-gnu/libc-2.21.so)
> ==24595==    by 0x52F1EA2: ??? (in /home/ryan/src/mlpack-tsp/build/lib/libmlpack.so.2.0)
> ==24595==    by 0x400F876: _dl_fini (in /lib/x86_64-linux-gnu/ld-2.21.so)
> ==24595==    by 0x7118E01: __run_exit_handlers (in /lib/x86_64-linux-gnu/libc-2.21.so)
> ==24595==    by 0x7118E54: exit (in /lib/x86_64-linux-gnu/libc-2.21.so)
> ==24595==    by 0x7103876: (below main) (in /lib/x86_64-linux-gnu/libc-2.21.so)
> ==24595==  Block was alloc'd at
> ==24595==    at 0x4C2A16F: operator new(unsigned long) (vg_replace_malloc.c:333)
> ==24595==    by 0x6529496: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
> ==24595==    by 0x65295EB: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
> ==24595==    by 0x53706E2: mlpack::util::PrefixedOutStream::PrefixedOutStream(std::ostream&, char const*, bool, bool) (prefixedoutstream.hpp:74)
> ==24595==    by 0x53705AA: __static_initialization_and_destruction_0(int, int) (log.cpp:44)
> ==24595==    by 0x537067C: _GLOBAL__sub_I_log.cpp (log.cpp:130)
> ==24595==    by 0x400F269: call_init.part.0 (in /lib/x86_64-linux-gnu/ld-2.21.so)
> ==24595==    by 0x400F37A: _dl_init (in /lib/x86_64-linux-gnu/ld-2.21.so)
> ==24595==    by 0x4000CC9: ??? (in /lib/x86_64-linux-gnu/ld-2.21.so)
> ==24595==    by 0x5: ???
> ==24595==    by 0xFFF000682: ???
> ==24595==    by 0xFFF000694: ???
> ... (lots more)
>
>> Reply to this email directly or view it on GitHub
> <https://github.com/mlpack/mlpack/pull/521#issuecomment-183386914>.
>



-- 
Joseph Chakravarti Mariadassou
http://thesundayprogrammer.com


---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/521#issuecomment-183600577
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160212/2654fa77/attachment-0001.html>


More information about the mlpack-git mailing list