While this doesn't crash on amd64, valgrind does find a double free in
test_index - and a comment in the test says checking that there isn't a
double free is the whole point of that test:
https://sources.debian.org/src/arrayfire/3.3.2+dfsg1-4/test/index.cpp/#L1255
==4773== Invalid free() / delete / delete[] / realloc()
==4773==at 0x4836EAB: operator delete(void*) (in
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==4773==by 0x525D4A4: releaseHandle (handle.hpp:109)
==4773==by 0x525D4A4: af_release_array (array.cpp:194)
==4773==by 0x1587FA: Indexing_SNIPPET_indexing_copy_Test::TestBody()
(index.cpp:1258)
==4773==by 0x291109:
HandleSehExceptionsInMethodIfSupported (gtest.cc:2443)
==4773==by 0x291109: void
testing::internal::HandleExceptionsInMethodIfSupportedvoid>(testing::Test*, void (testing::Test::*)(), char const*)
(gtest.cc:2479)
==4773==by 0x28780B: testing::Test::Run() [clone .part.611]
(gtest.cc:2517)
==4773==by 0x287AB4: Run (gtest.cc:2509)
==4773==by 0x287AB4: testing::TestInfo::Run() [clone .part.612]
(gtest.cc:2693)
==4773==by 0x287C53: Run (gtest.cc:2668)
==4773==by 0x287C53: testing::TestCase::Run() [clone .part.613]
(gtest.cc:2813)
==4773==by 0x2882C2: Run (gtest.cc:2799)
==4773==by 0x2882C2: testing::internal::UnitTestImpl::RunAllTests()
(gtest.cc:5179)
==4773==by 0x291619:
HandleSehExceptionsInMethodIfSupportedbool> (gtest.cc:2443)
==4773==by 0x291619: bool
testing::internal::HandleExceptionsInMethodIfSupportedbool>(testing::internal::UnitTestImpl*, bool
(testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2479)
==4773==by 0x288452: testing::UnitTest::Run() (gtest.cc:4788)
==4773==by 0x15820F: RUN_ALL_TESTS (gtest.h:2341)
==4773==by 0x15820F: main (gtest_main.cc:36)
==4773== Address 0x9d8d680 is 0 bytes inside a block of size 152 free'd
==4773==at 0x4836EAB: operator delete(void*) (in
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==4773==by 0x525D4A4: releaseHandle (handle.hpp:109)
==4773==by 0x525D4A4: af_release_array (array.cpp:194)
==4773==by 0x1587F2: Indexing_SNIPPET_indexing_copy_Test::TestBody()
(index.cpp:1259)
==4773==by 0x291109:
HandleSehExceptionsInMethodIfSupported (gtest.cc:2443)
==4773==by 0x291109: void
testing::internal::HandleExceptionsInMethodIfSupportedvoid>(testing::Test*, void (testing::Test::*)(), char const*)
(gtest.cc:2479)
==4773==by 0x28780B: testing::Test::Run() [clone .part.611]
(gtest.cc:2517)
==4773==by 0x287AB4: Run (gtest.cc:2509)
==4773==by 0x287AB4: testing::TestInfo::Run() [clone .part.612]
(gtest.cc:2693)
==4773==by 0x287C53: Run (gtest.cc:2668)
==4773==by 0x287C53: testing::TestCase::Run() [clone .part.613]
(gtest.cc:2813)
==4773==by 0x2882C2: Run (gtest.cc:2799)
==4773==by 0x2882C2: testing::internal::UnitTestImpl::RunAllTests()
(gtest.cc:5179)
==4773==by 0x291619:
HandleSehExceptionsInMethodIfSupportedbool> (gtest.cc:2443)
==4773==by 0x291619: bool
testing::internal::HandleExceptionsInMethodIfSupportedbool>(testing::internal::UnitTestImpl*, bool
(testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2479)
==4773==by 0x288452: testing::UnitTest::Run() (gtest.cc:4788)
==4773==by 0x15820F: RUN_ALL_TESTS (gtest.h:2341)
==4773==by 0x15820F: main (gtest_main.cc:36)
==4773== Block was alloc'd at
==4773==at 0x4835DEF: operator new(unsigned long) (in
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==4773==by 0x495AD03: cpu::Array* cpu::initArray()
(Array.cpp:162)
==4773==by 0x525DEE4: retainHandle (array.cpp:216)
==4773==by 0x525DEE4: retain(void*) (array.cpp:227)
==4773==by 0x525E32F: af_retain_array (array.cpp:245)
==4773==by 0x55304C3: af::index::index(af::array const&) (index.cpp:71)
==4773==by 0x1587DF: Indexing_SNIPPET_indexing_copy_Test::TestBody()
(index.cpp:1259)
==4773==by 0x291109:
HandleSehExceptionsInMethodIfSupported (gtest.cc:2443)
==4773==by 0x291109: void
testing::internal::HandleExceptionsInMethodIfSupportedvoid>(testing::Test*, void (testing::Test::*)(), char const*)
(gtest.cc:2479)
==4773==by 0x28780B: testing::Test::Run() [clone .part.611]
(gtest.cc:2517)
==4773==by 0x287AB4: Run (gtest.cc:2509)
==4773==by 0x287AB4: testing::TestInfo::Run() [clone .part.612]
(gtest.cc:2693)
==4773==by 0x287C53: Run (gtest.cc:2668)
==4773==by 0x287C53: testing::TestCase::Run() [clone .part.613]
(gtest.cc:2813)
==4773==by 0x2882C2: Run (gtest.cc:2799)
==4773==by 0x2882C2: testing::internal::UnitTestImpl::RunAllTests()
(gtest.cc:5179)
==4773==by 0x291619:
HandleSehExceptionsInMethodIfSupportedbool> (gtest.cc:2443)
==4773==by 0x291619: bool
testing::internal::HandleExceptionsInMethodIfSupportedbool>(testing::internal::UnitTestImpl*, bool
(testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2479)