Address sanitizer errors #4706
Replies: 2 comments 1 reply
-
Hello, sorry for taking a bit longer to create minimal example. CMake cmake_minimum_required (VERSION 3.14)
project (test)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set a default build type if none was specified
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
option(BUILD_ORTOOLS "Download and build ortools from source" OFF)
# Enable Address Sanitizer, default is OFF, except in Debug builds
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
option(ENABLE_ASAN "Enable address sanitizer" ON)
else()
option(ENABLE_ASAN "Enable address sanitizer" OFF)
endif()
if(ENABLE_ASAN)
message(STATUS "Enabling Address Sanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address -g")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address -g")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(DEPS_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps)
file(MAKE_DIRECTORY ${DEPS_DIR})
message(STATUS "Setting up OR Tools")
if(BUILD_ORTOOLS)
message("Downloading OR Tools source")
set(BUILD_DEPS ON)
set(BUILD_SAMPLES OFF)
set(BUILD_EXAMPLES OFF)
include(FetchContent)
FetchContent_Declare(
ortools
GIT_REPOSITORY https://github.com/google/or-tools.git
GIT_TAG v9.14
)
FetchContent_MakeAvailable(ortools)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/lib)
else()
message("Downloading prebuilt OR Tools binaries")
set(ORTOOLS_DIR ${DEPS_DIR}/ortools)
file(MAKE_DIRECTORY ${ORTOOLS_DIR})
set(ORTOOLS_ARCHIVE ${DEPS_DIR}/or-tools.tar.gz)
if(APPLE)
file(DOWNLOAD
https://github.com/google/or-tools/releases/download/v9.14/or-tools_arm64_macOS-15.5_cpp_v9.14.6206.tar.gz
${ORTOOLS_ARCHIVE}
EXPECTED_MD5 333621f5469e8337bd81f90d9360a6c8
)
endif()
if(UNIX AND NOT APPLE)
file(DOWNLOAD
https://github.com/google/or-tools/releases/download/v9.14/or-tools_amd64_ubuntu-24.04_cpp_v9.14.6206.tar.gz
${ORTOOLS_ARCHIVE}
EXPECTED_MD5 0aa596f6550d2f8a39c4ee9772093a05
)
endif()
execute_process(
COMMAND tar -xzf ${ORTOOLS_ARCHIVE} --strip-components=1 -C ${ORTOOLS_DIR}
WORKING_DIRECTORY ${DEPS_DIR}
)
file(GLOB ORTOOLS_CMAKE_FOLDERS "${ORTOOLS_DIR}/lib/cmake/*")
list(APPEND CMAKE_PREFIX_PATH ${ORTOOLS_CMAKE_FOLDERS})
find_package(ortools REQUIRED CONFIG)
include_directories(SYSTEM ${ORTOOLS_DIR}/include)
link_directories(${ORTOOLS_DIR}/lib)
endif()
message(STATUS "Setting up OR Tools done")
add_executable(test main.cc)
target_link_libraries(test
ortools::ortools
CbcSolver Cbc OsiCbc Cgl ClpSolver Clp OsiClp Osi CoinUtils
protobuf glog gflags
${OPENSSL_LIBRARIES}
)
main.cc #include <iostream>
#include "ortools/base/commandlineflags.h"
#include "ortools/base/logging.h"
#include "ortools/constraint_solver/routing.h"
#include "ortools/constraint_solver/routing_index_manager.h"
#include "ortools/constraint_solver/routing_parameters.h"
#include "ortools/constraint_solver/routing_parameters.pb.h"
using operations_research::RoutingIndexManager;
using operations_research::RoutingModel;
using operations_research::RoutingSearchParameters;
void SetUpTravelTimes(RoutingIndexManager &manager,
RoutingModel &model)
{
int vehicle_id = 0;
const int evaluator_index = model.RegisterTransitCallback(
[](
std::int64_t i, std::int64_t j) -> std::int64_t {
return 1;
}
);
model.SetArcCostEvaluatorOfVehicle(evaluator_index, vehicle_id++);
}
int main(int argc, char* argv[]) {
std::vector<operations_research::RoutingIndexManager::NodeIndex> vehicle_starts;
vehicle_starts.push_back(RoutingIndexManager::NodeIndex(1));
std::vector<operations_research::RoutingIndexManager::NodeIndex> vehicle_ends;
vehicle_ends.push_back(RoutingIndexManager::NodeIndex(0));
RoutingIndexManager manager(900, 1, vehicle_starts, vehicle_ends);
RoutingModel model(manager);
std::cout << model.Start(0) << std::endl;
return 0;
} |
Beta Was this translation helpful? Give feedback.
-
One more detail, the issues seem to start from v9.6, I've tried v9.5 and it worked as expected. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What version of OR-Tools and what language are you using?
Version: 9.14
Language: C++ (Clang 16 and GCC 14)
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
Routing Solver
What operating system (Linux, Windows, ...) and version?
Mac (ARM), Linux (Ubuntu 24.04)
Description
We've upgraded ortools from
v9.2
tov9.14
. And we've started seeing seemingly random ASAN errors in our project, unless we also build ORtools (and it's dependancies) with ASAN as well.One thing that I've noticed is that data from ortools components doesn't seem to be right, for example when I've tried reading
Assignment::IntervalVarContainer()::Elements()::size()
from one of solutions I've expected to get0
(which I did in above working configurations), but I've got gibberish value in project debug + asan + prebuilt ortools.I'll try to create minimal example, but in meantime I was wondering, have you ever ran into such issue?
Beta Was this translation helpful? Give feedback.
All reactions