[CppAD] CppAD Uninitialised value

joao joaoruileal at gmail.com
Fri Jan 9 09:18:01 EST 2015


Hello,

Some tests in CppADCodegen might have found an issue in the current version of CppAD (20150109).
I have attached the output generated by valgrind from running the test cppad/cg/operations/div.

The source for this test can be found at:
https://github.com/joaoleal/CppADCodeGen/blob/master/test/cppad/cg/operations/div.cpp
The relevant file that calls CppAD is:
https://github.com/joaoleal/CppADCodeGen/blob/master/test/cppad/cg/CppADCGOperationTestImpl.hpp

The issue in CppAD appears to be inside forward.hpp:
https://github.com/bradbell/cppad/blob/master/cppad/local/forward.hpp

which is called by sparse_jacobian.hpp at line 481:
https://github.com/bradbell/cppad/blob/master/cppad/local/sparse_jacobian.hpp


I may be missing something that I must do in CppADCodegen to adapt to the current version of CppAD.


Best regards,
João Rui Leal
-------------- next part --------------
==22759== Conditional jump or move depends on uninitialised value(s)
==22759==    at 0x5237CD: std::vector<double, std::allocator<double> > CppAD::ADFun<double>::Forward<std::vector<double, std::allocator<double> > >(unsigned long, unsigned long, std::vector<double, std::allocator<double> > const&) (forward.hpp:376)
==22759==    by 0x510FBA: unsigned long CppAD::ADFun<double>::SparseJacobianFor<std::vector<double, std::allocator<double> >, CppAD::sparse_pack, CppAD::vector<unsigned long> >(std::vector<double, std::allocator<double> > const&, CppAD::sparse_pack&, CppAD::vector<unsigned long> const&, CppAD::vector<unsigned long> const&, std::vector<double, std::allocator<double> >&, CppAD::sparse_jacobian_work&) (sparse_jacobian.hpp:481)
==22759==    by 0x4EA56A: std::vector<double, std::allocator<double> > CppAD::ADFun<double>::SparseJacobian<std::vector<double, std::allocator<double> >, CppAD::vectorBool>(std::vector<double, std::allocator<double> > const&, CppAD::vectorBool const&) (sparse_jacobian.hpp:957)
==22759==    by 0x4D92A9: std::vector<double, std::allocator<double> > CppAD::ADFun<double>::SparseJacobian<std::vector<double, std::allocator<double> > >(std::vector<double, std::allocator<double> > const&) (sparse_jacobian.hpp:1052)
==22759==    by 0x4C88A1: CppAD::cg::CppADCGOperationTest::runSparseJacDefault(CppAD::ADFun<double>&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&) (CppADCGOperationTestImpl.hpp:255)
==22759==    by 0x4C959B: CppAD::cg::CppADCGOperationTest::test0nJac(std::string const&, CppAD::ADFun<double>* (*)(std::vector<CppAD::AD<double>, std::allocator<CppAD::AD<double> > > const&), CppAD::ADFun<CppAD::cg::CG<double> >* (*)(std::vector<CppAD::AD<CppAD::cg::CG<double> >, std::allocator<CppAD::AD<CppAD::cg::CG<double> > > > const&), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, double, double) (CppADCGOperationTestImpl.hpp:367)
==22759==    by 0x4C93C3: CppAD::cg::CppADCGOperationTest::test0nJac(std::string const&, CppAD::ADFun<double>* (*)(std::vector<CppAD::AD<double>, std::allocator<CppAD::AD<double> > > const&), CppAD::ADFun<CppAD::cg::CG<double> >* (*)(std::vector<CppAD::AD<CppAD::cg::CG<double> >, std::allocator<CppAD::AD<CppAD::cg::CG<double> > > > const&), std::vector<double, std::allocator<double> > const&, double, double) (CppADCGOperationTestImpl.hpp:340)
==22759==    by 0x4CA749: CppADCGOperationTest_DivTestOne_Test::TestBody() (div.cpp:25)
==22759==    by 0x5A6E18: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x5A222D: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x58F9CA: testing::Test::Run() (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x590147: testing::TestInfo::Run() (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x590711: testing::TestCase::Run() (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x59544F: testing::internal::UnitTestImpl::RunAllTests() (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x5A8235: bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x5A308D: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==  Uninitialised value was created by a heap allocation
==22759==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22759==    by 0x4CCDD2: CppAD::thread_alloc::get_memory(unsigned long, unsigned long&) (thread_alloc.hpp:898)
==22759==    by 0x4EF470: CppAD::pod_vector<double>::extend(unsigned long) (pod_vector.hpp:166)
==22759==    by 0x4DE8D5: CppAD::ADFun<double>::capacity_order(unsigned long, unsigned long) (capacity_order.hpp:181)
==22759==    by 0x5232DC: std::vector<double, std::allocator<double> > CppAD::ADFun<double>::Forward<std::vector<double, std::allocator<double> > >(unsigned long, unsigned long, std::vector<double, std::allocator<double> > const&) (forward.hpp:321)
==22759==    by 0x510FBA: unsigned long CppAD::ADFun<double>::SparseJacobianFor<std::vector<double, std::allocator<double> >, CppAD::sparse_pack, CppAD::vector<unsigned long> >(std::vector<double, std::allocator<double> > const&, CppAD::sparse_pack&, CppAD::vector<unsigned long> const&, CppAD::vector<unsigned long> const&, std::vector<double, std::allocator<double> >&, CppAD::sparse_jacobian_work&) (sparse_jacobian.hpp:481)
==22759==    by 0x4EA56A: std::vector<double, std::allocator<double> > CppAD::ADFun<double>::SparseJacobian<std::vector<double, std::allocator<double> >, CppAD::vectorBool>(std::vector<double, std::allocator<double> > const&, CppAD::vectorBool const&) (sparse_jacobian.hpp:957)
==22759==    by 0x4D92A9: std::vector<double, std::allocator<double> > CppAD::ADFun<double>::SparseJacobian<std::vector<double, std::allocator<double> > >(std::vector<double, std::allocator<double> > const&) (sparse_jacobian.hpp:1052)
==22759==    by 0x4C88A1: CppAD::cg::CppADCGOperationTest::runSparseJacDefault(CppAD::ADFun<double>&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&) (CppADCGOperationTestImpl.hpp:255)
==22759==    by 0x4C959B: CppAD::cg::CppADCGOperationTest::test0nJac(std::string const&, CppAD::ADFun<double>* (*)(std::vector<CppAD::AD<double>, std::allocator<CppAD::AD<double> > > const&), CppAD::ADFun<CppAD::cg::CG<double> >* (*)(std::vector<CppAD::AD<CppAD::cg::CG<double> >, std::allocator<CppAD::AD<CppAD::cg::CG<double> > > > const&), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, double, double) (CppADCGOperationTestImpl.hpp:367)
==22759==    by 0x4C93C3: CppAD::cg::CppADCGOperationTest::test0nJac(std::string const&, CppAD::ADFun<double>* (*)(std::vector<CppAD::AD<double>, std::allocator<CppAD::AD<double> > > const&), CppAD::ADFun<CppAD::cg::CG<double> >* (*)(std::vector<CppAD::AD<CppAD::cg::CG<double> >, std::allocator<CppAD::AD<CppAD::cg::CG<double> > > > const&), std::vector<double, std::allocator<double> > const&, double, double) (CppADCGOperationTestImpl.hpp:340)
==22759==    by 0x4CA749: CppADCGOperationTest_DivTestOne_Test::TestBody() (div.cpp:25)
==22759==    by 0x5A6E18: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x5A222D: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x58F9CA: testing::Test::Run() (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759==    by 0x590147: testing::TestInfo::Run() (in /home/joao/Development/CppADCodeGen/build/test/cppad/cg/operations/div)
==22759== 


More information about the CppAD mailing list