coin-or / SHOT

A solver for mixed-integer nonlinear optimization problems
https://shotsolver.dev
Eclipse Public License 2.0
117 stars 25 forks source link

cutOffToUse used uninitialized #156

Closed svigerske closed 2 years ago

svigerske commented 2 years ago

From running GAMS modellib model windfac, I'm getting these from valgrind:

 Performing bound tightening on reformulated problem.
  - Bounds for 2 variables tightened in 0.16 s and 2 passes.
  - Objective bounds are: [0, 2e+100]
==4032271== Conditional jump or move depends on uninitialised value(s)
==4032271==    at 0x5B79F74: SHOT::TaskPerformBoundTightening::run() (TaskPerformBoundTightening.cpp:148)
==4032271==    by 0x5B805AA: SHOT::TaskReformulateProblem::TaskReformulateProblem(std::shared_ptr<SHOT::Environment>) (TaskReformulateProblem.cpp:282)
==4032271==    by 0x592998D: std::__detail::_MakeUniq<SHOT::TaskReformulateProblem>::__single_object std::make_unique<SHOT::TaskReformulateProblem, std::shared_ptr<SHOT::Environment>&>(std::shared_ptr<SHOT::Environment>&) (unique_ptr.h:1065)
==4032271==    by 0x5903B9C: SHOT::Solver::setProblem(std::shared_ptr<SHOT::Problem>, std::shared_ptr<SHOT::Problem>, std::shared_ptr<SHOT::IModelingSystem>) (Solver.cpp:480)
==4032271==    by 0x5A14180: SHOT::Solver::setProblem(std::shared_ptr<SHOT::Problem>, std::shared_ptr<SHOT::IModelingSystem>) (Solver.h:68)
==4032271==    by 0x5A13039: shtCallSolver (EntryPointsGAMS.cpp:202)
==4032271==    by 0x5A137DA: C__shtCallSolver (EntryPointsGAMS.cpp:270)
==4032271==    by 0x5332AD5: GMSCONF_tgmsconf_DOT_sccallsolver(GMSCONF_tgmsconf_OD_S*, int, void*, void*) (gmsconf.c:2783)
==4032271==    by 0x53262AB: libsolver(unsigned char*, unsigned char*, unsigned char const*, GMOMDODEFEX_tgmomodel_OD_S**, GEVDOORG_tgmsenvironment_OD_S**) (gevdoorg.c:3091)
==4032271==    by 0x53279AE: GEVDOORG_tgmsenvironment_DOT_gevcallsolver(GEVDOORG_tgmsenvironment_OD_S*, void*, unsigned char const*, unsigned char const*, int, int, unsigned char const*, unsigned char const*, double, int, int, double, double, void**, unsigned char*) (gevdoorg.c:3480)
==4032271==    by 0x52B268A: gevcallsolver (joatdclib.c:5251)
==4032271==    by 0x126DE7: GEVMDODEF_tgmsenvironment_DOT_gevcallsolver(GEVMDODEF_tgmsenvironment_OD_S*, void*, unsigned char const*, unsigned char const*, int, int, unsigned char const*, unsigned char const*, double, int, int, double, double, void**, unsigned char*) (gevmdodef.c:853)
==4032271==  Uninitialised value was created by a heap allocation
==4032271==    at 0x4846003: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4032271==    by 0x5933C8C: std::__new_allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (new_allocator.h:137)
==4032271==    by 0x59322FC: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (alloc_traits.h:464)
==4032271==    by 0x5930C21: std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&) (allocated_ptr.h:98)
==4032271==    by 0x592F031: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<SHOT::DualSolver, std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(SHOT::DualSolver*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr_base.h:969)
==4032271==    by 0x592D40B: std::__shared_ptr<SHOT::DualSolver, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr_base.h:1712)
==4032271==    by 0x592B6D6: std::shared_ptr<SHOT::DualSolver>::shared_ptr<std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr.h:464)
==4032271==    by 0x5928FDB: std::shared_ptr<std::enable_if<!std::is_array<SHOT::DualSolver>::value, SHOT::DualSolver>::type> std::make_shared<SHOT::DualSolver, std::shared_ptr<SHOT::Environment>&>(std::shared_ptr<SHOT::Environment>&) (shared_ptr.h:1010)
==4032271==    by 0x58FEC18: SHOT::Solver::Solver(std::shared_ptr<spdlog::sinks::sink>) (Solver.cpp:112)
==4032271==    by 0x5A12A60: shtCallSolver (EntryPointsGAMS.cpp:155)
==4032271==    by 0x5A137DA: C__shtCallSolver (EntryPointsGAMS.cpp:270)
==4032271==    by 0x5332AD5: GMSCONF_tgmsconf_DOT_sccallsolver(GMSCONF_tgmsconf_OD_S*, int, void*, void*) (gmsconf.c:2783)
==4032271== 
==4032271== Conditional jump or move depends on uninitialised value(s)
==4032271==    at 0x58D5F36: SHOT::Results::setPrimalBound(double) (Results.cpp:1117)
==4032271==    by 0x5903C62: SHOT::Solver::setProblem(std::shared_ptr<SHOT::Problem>, std::shared_ptr<SHOT::Problem>, std::shared_ptr<SHOT::IModelingSystem>) (Solver.cpp:487)
==4032271==    by 0x5A14180: SHOT::Solver::setProblem(std::shared_ptr<SHOT::Problem>, std::shared_ptr<SHOT::IModelingSystem>) (Solver.h:68)
==4032271==    by 0x5A13039: shtCallSolver (EntryPointsGAMS.cpp:202)
==4032271==    by 0x5A137DA: C__shtCallSolver (EntryPointsGAMS.cpp:270)
==4032271==    by 0x5332AD5: GMSCONF_tgmsconf_DOT_sccallsolver(GMSCONF_tgmsconf_OD_S*, int, void*, void*) (gmsconf.c:2783)
==4032271==    by 0x53262AB: libsolver(unsigned char*, unsigned char*, unsigned char const*, GMOMDODEFEX_tgmomodel_OD_S**, GEVDOORG_tgmsenvironment_OD_S**) (gevdoorg.c:3091)
==4032271==    by 0x53279AE: GEVDOORG_tgmsenvironment_DOT_gevcallsolver(GEVDOORG_tgmsenvironment_OD_S*, void*, unsigned char const*, unsigned char const*, int, int, unsigned char const*, unsigned char const*, double, int, int, double, double, void**, unsigned char*) (gevdoorg.c:3480)
==4032271==    by 0x52B268A: gevcallsolver (joatdclib.c:5251)
==4032271==    by 0x126DE7: GEVMDODEF_tgmsenvironment_DOT_gevcallsolver(GEVMDODEF_tgmsenvironment_OD_S*, void*, unsigned char const*, unsigned char const*, int, int, unsigned char const*, unsigned char const*, double, int, int, double, double, void**, unsigned char*) (gevmdodef.c:853)
==4032271==    by 0x10F614: main (genlink.c:266)
==4032271==  Uninitialised value was created by a heap allocation
==4032271==    at 0x4846003: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4032271==    by 0x5933C8C: std::__new_allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (new_allocator.h:137)
==4032271==    by 0x59322FC: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (alloc_traits.h:464)
==4032271==    by 0x5930C21: std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&) (allocated_ptr.h:98)
==4032271==    by 0x592F031: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<SHOT::DualSolver, std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(SHOT::DualSolver*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr_base.h:969)
==4032271==    by 0x592D40B: std::__shared_ptr<SHOT::DualSolver, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr_base.h:1712)
==4032271==    by 0x592B6D6: std::shared_ptr<SHOT::DualSolver>::shared_ptr<std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr.h:464)
==4032271==    by 0x5928FDB: std::shared_ptr<std::enable_if<!std::is_array<SHOT::DualSolver>::value, SHOT::DualSolver>::type> std::make_shared<SHOT::DualSolver, std::shared_ptr<SHOT::Environment>&>(std::shared_ptr<SHOT::Environment>&) (shared_ptr.h:1010)
==4032271==    by 0x58FEC18: SHOT::Solver::Solver(std::shared_ptr<spdlog::sinks::sink>) (Solver.cpp:112)
==4032271==    by 0x5A12A60: shtCallSolver (EntryPointsGAMS.cpp:155)
==4032271==    by 0x5A137DA: C__shtCallSolver (EntryPointsGAMS.cpp:270)
==4032271==    by 0x5332AD5: GMSCONF_tgmsconf_DOT_sccallsolver(GMSCONF_tgmsconf_OD_S*, int, void*, void*) (gmsconf.c:2783)
==4032271== 

I think they refer to env->dualSolver->cutOffToUse.

Further down there is also

==4032271== Conditional jump or move depends on uninitialised value(s)
==4032271==    at 0x58B6DC2: SHOT::Report::outputIterationDetail(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double, int, int, double, double, double, double, double, int, double, SHOT::E_IterationLineType, bool) (Report.cpp:53)
==4032271==    by 0x5BB63AD: SHOT::TaskRepairInfeasibleDualProblem::run() (TaskRepairInfeasibleDualProblem.cpp:147)
==4032271==    by 0x5B4D7AE: SHOT::SolutionStrategyMultiTree::solveProblem() (SolutionStrategyMultiTree.cpp:330)
==4032271==    by 0x59062A7: SHOT::Solver::solveProblem() (Solver.cpp:653)
==4032271==    by 0x5A13182: shtCallSolver (EntryPointsGAMS.cpp:213)
==4032271==    by 0x5A137DA: C__shtCallSolver (EntryPointsGAMS.cpp:270)
==4032271==    by 0x5332AD5: GMSCONF_tgmsconf_DOT_sccallsolver(GMSCONF_tgmsconf_OD_S*, int, void*, void*) (gmsconf.c:2783)
==4032271==    by 0x53262AB: libsolver(unsigned char*, unsigned char*, unsigned char const*, GMOMDODEFEX_tgmomodel_OD_S**, GEVDOORG_tgmsenvironment_OD_S**) (gevdoorg.c:3091)
==4032271==    by 0x53279AE: GEVDOORG_tgmsenvironment_DOT_gevcallsolver(GEVDOORG_tgmsenvironment_OD_S*, void*, unsigned char const*, unsigned char const*, int, int, unsigned char const*, unsigned char const*, double, int, int, double, double, void**, unsigned char*) (gevdoorg.c:3480)
==4032271==    by 0x52B268A: gevcallsolver (joatdclib.c:5251)
==4032271==    by 0x126DE7: GEVMDODEF_tgmsenvironment_DOT_gevcallsolver(GEVMDODEF_tgmsenvironment_OD_S*, void*, unsigned char const*, unsigned char const*, int, int, unsigned char const*, unsigned char const*, double, int, int, double, double, void**, unsigned char*) (gevmdodef.c:853)
==4032271==    by 0x10F614: main (genlink.c:266)
==4032271==  Uninitialised value was created by a heap allocation
==4032271==    at 0x4846003: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4032271==    by 0x5933C8C: std::__new_allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (new_allocator.h:137)
==4032271==    by 0x59322FC: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (alloc_traits.h:464)
==4032271==    by 0x5930C21: std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<SHOT::DualSolver, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >&) (allocated_ptr.h:98)
==4032271==    by 0x592F031: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<SHOT::DualSolver, std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(SHOT::DualSolver*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr_base.h:969)
==4032271==    by 0x592D40B: std::__shared_ptr<SHOT::DualSolver, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr_base.h:1712)
==4032271==    by 0x592B6D6: std::shared_ptr<SHOT::DualSolver>::shared_ptr<std::allocator<void>, std::shared_ptr<SHOT::Environment>&>(std::_Sp_alloc_shared_tag<std::allocator<void> >, std::shared_ptr<SHOT::Environment>&) (shared_ptr.h:464)
==4032271==    by 0x5928FDB: std::shared_ptr<std::enable_if<!std::is_array<SHOT::DualSolver>::value, SHOT::DualSolver>::type> std::make_shared<SHOT::DualSolver, std::shared_ptr<SHOT::Environment>&>(std::shared_ptr<SHOT::Environment>&) (shared_ptr.h:1010)
==4032271==    by 0x58FEC18: SHOT::Solver::Solver(std::shared_ptr<spdlog::sinks::sink>) (Solver.cpp:112)
==4032271==    by 0x5A12A60: shtCallSolver (EntryPointsGAMS.cpp:155)
==4032271==    by 0x5A137DA: C__shtCallSolver (EntryPointsGAMS.cpp:270)
==4032271==    by 0x5332AD5: GMSCONF_tgmsconf_DOT_sccallsolver(GMSCONF_tgmsconf_OD_S*, int, void*, void*) (gmsconf.c:2783)

The source line is

        if(primalObjectiveValue != lastPrimalObjectiveValue)