Undefined behavior if I call routing.SolveWithParametersmultiple times?

81 views
Skip to first unread message

ces147

unread,
Aug 25, 2025, 9:25:51 PMAug 25
to or-tools-discuss
In my code, I have:

const operations_research::Assignment* solution;
detail::cleanupSecsNanos(search_time_limit_seconds, search_time_limit_nanos);
search_parameters.mutable_time_limit()->set_seconds(search_time_limit_seconds);
search_parameters.mutable_time_limit()->set_nanos(search_time_limit_nanos);

solution = routing.SolveWithParameters(search_parameters);


and then I check if (routing.status() ==
operations_research::RoutingModel::Status::ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED || routing.status() == operations_research::RoutingModel::Status::ROUTING_FAIL_TIMEOUT)


And if it is, I increase the search time limit and try again ... I get ASAN errors sometimes but not all the time, related to the destructor of Assignment:

==1266821==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_allocator.cpp:189 "((old)) == ((kAllocBegMagic))" (0xcc6e96b9cc6e9601, 0xcc6e96b9cc6e96b9)

#0 0x76d682ebd9a8 in AsanCheckFailed ../../../../src/libsanitizer/asan/asan_rtl.cpp:74

#1 0x76d682ede32e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:78

#2 0x76d682e2b309 in __asan::LargeChunkHeader::Set(__asan::AsanChunk*) ../../../../src/libsanitizer/asan/asan_allocator.cpp:189

#3 0x76d682e2b309 in __asan::LargeChunkHeader::Set(__asan::AsanChunk*) ../../../../src/libsanitizer/asan/asan_allocator.cpp:179

#4 0x76d682e2b309 in __asan::QuarantineCallback::Recycle(__asan::AsanChunk*) ../../../../src/libsanitizer/asan/asan_allocator.cpp:205

#5 0x76d682e2b309 in __sanitizer::Quarantine<__asan::QuarantineCallback, __asan::AsanChunk>::DoRecycle(__sanitizer::QuarantineCache<__asan::QuarantineCallback>*, __asan::QuarantineCallback) ../../../../src/libsanitizer/sanitizer_common/sanitizer_quarantine.h:192

#6 0x76d682e2b6ed in __sanitizer::Quarantine<__asan::QuarantineCallback, __asan::AsanChunk>::Recycle(unsigned long, __asan::QuarantineCallback) ../../../../src/libsanitizer/sanitizer_common/sanitizer_quarantine.h:180

#7 0x76d682e2899f in __sanitizer::Quarantine<__asan::QuarantineCallback, __asan::AsanChunk>::Put(__sanitizer::QuarantineCache<__asan::QuarantineCallback>*, __asan::QuarantineCallback, __asan::AsanChunk*, unsigned long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_quarantine.h:112

#8 0x76d682e2899f in __asan::Allocator::QuarantineChunk(__asan::AsanChunk*, void*, __sanitizer::BufferedStackTrace*) ../../../../src/libsanitizer/asan/asan_allocator.cpp:666

#9 0x76d682eb720c in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:172

#10 0x76d6686de259 in __gnu_cxx::new_allocator<operations_research::DimensionChecker::ExtendedInterval>::deallocate(operations_research::DimensionChecker::ExtendedInterval*, unsigned long) /usr/include/c++/11/ext/new_allocator.h:145

#11 0x76d6686d693b in std::allocator_traits<std::allocator<operations_research::DimensionChecker::ExtendedInterval> >::deallocate(std::allocator<operations_research::DimensionChecker::ExtendedInterval>&, operations_research::DimensionChecker::ExtendedInterval*, unsigned long) /usr/include/c++/11/bits/alloc_traits.h:496

#12 0x76d6686ce155 in std::_Vector_base<operations_research::DimensionChecker::ExtendedInterval, std::allocator<operations_research::DimensionChecker::ExtendedInterval> >::_M_deallocate(operations_research::DimensionChecker::ExtendedInterval*, unsigned long) /usr/include/c++/11/bits/stl_vector.h:354

#13 0x76d6686ce77e in std::vector<operations_research::DimensionChecker::ExtendedInterval, std::allocator<operations_research::DimensionChecker::ExtendedInterval> >::_M_default_append(unsigned long) (/home/cristina/.conan2/p/ortoof66c9fd81d29d/p/lib/libortools.so.9+0x22ce77e)

#14 0x76d6686c50c2 in std::vector<operations_research::DimensionChecker::ExtendedInterval, std::allocator<operations_research::DimensionChecker::ExtendedInterval> >::resize(unsigned long) (/home/cristina/.conan2/p/ortoof66c9fd81d29d/p/lib/libortools.so.9+0x22c50c2)

#15 0x76d6686a2921 in operations_research::DimensionChecker::UpdateRIQStructure(int, int) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/local_search.cc:3368

#16 0x76d6686a1ca0 in operations_research::DimensionChecker::IncrementalCommit() /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/local_search.cc:3292

#17 0x76d6686a1bab in operations_research::DimensionChecker::Commit() /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/local_search.cc:3282

#18 0x76d6686a375f in Synchronize /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/local_search.cc:3460

#19 0x76d6686a66fd in operations_research::LocalSearchFilterManager::Synchronize(operations_research::Assignment const*, operations_research::Assignment const*) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/local_search.cc:4395

#20 0x76d6689248f7 in operations_research::IntVarFilteredHeuristic::SynchronizeFilters() /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing_search.cc:392

#21 0x76d66892477c in operations_research::IntVarFilteredHeuristic::Evaluate(bool) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing_search.cc:377

#22 0x76d668933ef2 in operations_research::CheapestAdditionFilteredHeuristic::BuildSolutionInternal() /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing_search.cc:2768

#23 0x76d66892423a in operations_research::IntVarFilteredHeuristic::BuildSolution() /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing_search.cc:310

#24 0x76d668923a9d in operations_research::IntVarFilteredDecisionBuilder::Next(operations_research::Solver*) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing_search.cc:242

#25 0x76d6689b203b in Next /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/search.cc:729

#26 0x76d6689b1663 in Next /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/search.cc:584

#27 0x76d66856f5be in operations_research::Solver::NextSolution() /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/constraint_solver.cc:2197

#28 0x76d668570e76 in operations_research::Solver::SolveAndCommit(operations_research::DecisionBuilder*, std::vector<operations_research::SearchMonitor*, std::allocator<operations_research::SearchMonitor*> > const&) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/constraint_solver.cc:2441

#29 0x76d6686a89ba in Apply /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/local_search.cc:4892

#30 0x76d66856f783 in operations_research::Solver::NextSolution() /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/constraint_solver.cc:2217

#31 0x76d66856d0b8 in operations_research::Solver::Solve(operations_research::DecisionBuilder*, std::vector<operations_research::SearchMonitor*, std::allocator<operations_research::SearchMonitor*> > const&) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/constraint_solver.cc:1825

#32 0x76d66876ce65 in operations_research::RoutingModel::SolveFromAssignmentsWithParameters(std::vector<operations_research::Assignment const*, std::allocator<operations_research::Assignment const*> > const&, operations_research::RoutingSearchParameters const&, std::vector<operations_research::Assignment const*, std::allocator<operations_research::Assignment const*> >*) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing.cc:2625

#33 0x76d66876c435 in operations_research::RoutingModel::SolveFromAssignmentWithParameters(operations_research::Assignment const*, operations_research::RoutingSearchParameters const&, std::vector<operations_research::Assignment const*, std::allocator<operations_research::Assignment const*> >*) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing.cc:2533

#34 0x76d66876bc10 in operations_research::RoutingModel::SolveWithParameters(operations_research::RoutingSearchParameters const&, std::vector<operations_research::Assignment const*, std::allocator<operations_research::Assignment const*> >*) /home/AzDevOps_azpcontainer/.conan2/p/b/ortood821e78b6088a/b/ortools/constraint_solver/routing.cc:2462


Any thoughts?

Vincent Furnon

unread,
Aug 26, 2025, 8:15:47 AMAug 26
to or-tools...@googlegroups.com
Hi,
What version of or-tools are you using ?


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/or-tools-discuss/2cdc1f49-e128-4b68-9db2-4817f3fe6d71n%40googlegroups.com.
Message has been deleted
Message has been deleted

Cristina Sorice

unread,
Aug 26, 2025, 11:58:43 AMAug 26
to or-tools...@googlegroups.com
v9.7 C++

---




You received this message because you are subscribed to a topic in the Google Groups "or-tools-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/or-tools-discuss/F9wmZL6EW6Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to or-tools-discu...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/or-tools-discuss/CAPz%2Bj2W_xa5Np8-AOs_%2B%2B0H%3Da6z2DQarz29T1uAzSD2b3UFY9g%40mail.gmail.com.

ces147

unread,
Aug 27, 2025, 1:59:47 AMAug 27
to or-tools-discuss
v9.7, C++

Vincent Furnon

unread,
Aug 27, 2025, 4:43:40 AMAug 27
to or-tools...@googlegroups.com

Cristina Sorice

unread,
Aug 27, 2025, 12:00:07 PMAug 27
to or-tools...@googlegroups.com
I'm not sure that I can upgrade my project because I'm not the only user but I will look into it.

Can you provide any links or docs about why 9.14 would solve this issue? I didn't see anything about it in the Google group or the GitHub issues. 

You received this message because you are subscribed to a topic in the Google Groups "or-tools-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/or-tools-discuss/F9wmZL6EW6Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to or-tools-discu...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/or-tools-discuss/CAPz%2Bj2W2ACHvMRn0114u%3DL0NK0n7YBHqXyzmpPD0paQXtfTCAQ%40mail.gmail.com.

Vincent Furnon

unread,
Aug 27, 2025, 12:17:20 PMAug 27
to or-tools...@googlegroups.com
The code has changed a lot between 9.7 and 9.14, especially the one raising the ASAN issue.

Cristina Sorice

unread,
Aug 27, 2025, 3:50:19 PMAug 27
to or-tools...@googlegroups.com
Is there a known issue documented somewhere, or a bug documented? I couldn't find any info about it.

It looks like I can't make the upgrade right now. I'm stuck on C++17 for my project. I'll review the code changes but if you could point me to any docs or conversations about the issue that would be very helpful.

Vincent Furnon

unread,
Aug 28, 2025, 4:35:20 AMAug 28
to or-tools...@googlegroups.com
Actually this is the first time we see this issue.

Reply all
Reply to author
Forward
0 new messages