Skip to content

Expressions cause segfault on Windows (MSVC 2019 v16) #1336

@laxnpander

Description

@laxnpander

Description

Expressions seem to cause a segfault on Windows 2019 v16 (potentially others as well). None of the examples with expressions work. According to the debugger, the following line causes the crash (ExpressionNode.h, L279):

    Record(const Values& values, const ExpressionNode<A1>& expression1, ExecutionTraceStorage* ptr)
        : value1(expression1.traceExecution(values, trace1, ptr + upAligned(sizeof(Record)))) {}

Stacktrace:

 	SFMExampleExpressions.exe!gtsam::internal::CallRecord<2>::CallRecord<2>()	C++
 	SFMExampleExpressions.exe!gtsam::internal::CallRecordImplementor<gtsam::internal::UnaryExpression<Eigen::Matrix<double,2,1,0,2,1>,Eigen::Matrix<double,3,1,0,3,1>>::Record,2>::CallRecordImplementor<gtsam::internal::UnaryExpression<Eigen::Matrix<double,2,1,0,2,1>,Eigen::Matrix<double,3,1,0,3,1>>::Record,2>()	C++
>	SFMExampleExpressions.exe!gtsam::internal::UnaryExpression<Eigen::Matrix<double,2,1,0,2,1>,Eigen::Matrix<double,3,1,0,3,1>>::Record::Record(const gtsam::Values & values, const gtsam::internal::ExpressionNode<Eigen::Matrix<double,3,1,0,3,1>> & expression1, boost::detail::aligned_storage::aligned_storage_imp<1,32> * ptr) Line 280	C++
 	SFMExampleExpressions.exe!gtsam::internal::UnaryExpression<Eigen::Matrix<double,2,1,0,2,1>,Eigen::Matrix<double,3,1,0,3,1>>::traceExecution(const gtsam::Values & values, gtsam::internal::ExecutionTrace<Eigen::Matrix<double,2,1,0,2,1>> & trace, boost::detail::aligned_storage::aligned_storage_imp<1,32> * ptr) Line 322	C++
 	SFMExampleExpressions.exe!gtsam::internal::BinaryExpression<Eigen::Matrix<double,2,1,0,2,1>,gtsam::Cal3_S2,Eigen::Matrix<double,2,1,0,2,1>>::Record::Record(const gtsam::Values & values, const gtsam::internal::ExpressionNode<gtsam::Cal3_S2> & expression1, const gtsam::internal::ExpressionNode<Eigen::Matrix<double,2,1,0,2,1>> & expression2, boost::detail::aligned_storage::aligned_storage_imp<1,32> * ptr) Line 404	C++
 	SFMExampleExpressions.exe!gtsam::internal::BinaryExpression<Eigen::Matrix<double,2,1,0,2,1>,gtsam::Cal3_S2,Eigen::Matrix<double,2,1,0,2,1>>::traceExecution(const gtsam::Values & values, gtsam::internal::ExecutionTrace<Eigen::Matrix<double,2,1,0,2,1>> & trace, boost::detail::aligned_storage::aligned_storage_imp<1,32> * ptr) Line 432	C++
 	SFMExampleExpressions.exe!gtsam::Expression<Eigen::Matrix<double,2,1,0,2,1>>::traceExecution(const gtsam::Values & values, gtsam::internal::ExecutionTrace<Eigen::Matrix<double,2,1,0,2,1>> & trace, void * traceStorage) Line 193	C++
 	SFMExampleExpressions.exe!gtsam::Expression<Eigen::Matrix<double,2,1,0,2,1>>::valueAndJacobianMap(const gtsam::Values & values, gtsam::internal::JacobianMap & jacobians) Line 218	C++
 	SFMExampleExpressions.exe!gtsam::ExpressionFactor<Eigen::Matrix<double,2,1,0,2,1>>::linearize(const gtsam::Values & x) Line 139	C++
 	gtsamDebug.dll!gtsam::NonlinearFactorGraph::linearize(const gtsam::Values & linearizationPoint) Line 270	C++
 	gtsamDebug.dll!gtsam::DoglegOptimizer::iterate() Line 87	C++
 	gtsamDebug.dll!gtsam::NonlinearOptimizer::defaultOptimize() Line 95	C++
 	gtsamDebug.dll!gtsam::NonlinearOptimizer::optimize() Line 98	C++
 	SFMExampleExpressions.exe!main(int argc, char * * argv) Line 95	C++

Steps to reproduce

CMake configuration is with GTSAM_BUILD_UNSTABLE=OFF and GTSAM_BUILD_PYTHON=OFF. Compiler used is MSVC2019 v16 with Boost 1.72 and GTSAM version of Eigen3.

D:\Workspace\spear\spear\3rd\gtsam\cmake-build>cmake --build . --config debug
CMake is re-running because D:/Workspace/spear/spear/3rd/gtsam/cmake-build/examples/CMakeFiles/generate.stamp is out-of-date.
  the file 'D:/Workspace/spear/spear/3rd/gtsam/examples/CMakeLists.txt'
  is newer than 'D:/Workspace/spear/spear/3rd/gtsam/cmake-build/examples/CMakeFiles/generate.stamp.depend'
  result='-1'
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- GTSAM Version: 4.2a7
-- GTSAM_POSE3_EXPMAP=ON, enabling GTSAM_ROT3_EXPMAP as well
-- Found Eigen version: 3.3.7
-- Could NOT find MKL (missing: MKL_INCLUDE_DIR MKL_LIBRARIES)
-- Could NOT find TBB (missing: TBB_INCLUDE_DIRS TBB_LIBRARIES tbb tbbmalloc) (Required is at least version "4.4")
-- Building 3rdparty
-- Could NOT find GeographicLib (missing: GeographicLib_LIBRARY_DIRS GeographicLib_LIBRARIES GeographicLib_INCLUDE_DIRS)
-- Building base
-- Building basis
-- Building geometry
-- Building inference
-- Building symbolic
-- Building discrete
-- Building hybrid
-- Building linear
-- Building nonlinear
-- Building sam
-- Building sfm
-- Building slam
-- Building navigation
-- Adding precompiled header for MSVC
-- GTSAM Version: 4.2.0
-- Install prefix: D:/Workspace/spear/spear/3rd/gtsam/install
-- Building GTSAM - shared: ON
-- Wrote D:/Workspace/spear/spear/3rd/gtsam/cmake-build/GTSAMConfig.cmake
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- ===============================================================
-- ================  Configuration Options  ======================
--  CMAKE_CXX_COMPILER_ID type                       : MSVC
--  CMAKE_CXX_COMPILER_VERSION                       : 19.29.30146.0
--  CMake version                                    : 3.23.1
--  CMake generator                                  : Visual Studio 16 2019
--  CMake build tool                                 : C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
-- Build flags
--  Build Tests                                      : Enabled
--  Build examples with 'make all'                   : Enabled
--  Build timing scripts with 'make all'             : Disabled
--  Build shared GTSAM libraries                     : Enabled
--  Put build type in library name                   : Enabled
--  Build libgtsam_unstable                          : Disabled
--  Build GTSAM unstable Python                      : Enabled
--  Build MATLAB Toolbox for unstable                : Disabled
--  GTSAM_COMPILE_FEATURES_PUBLIC                    : cxx_std_11
--  GTSAM_COMPILE_OPTIONS_PUBLIC                     : /wd4267
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC                 : EIGEN_NO_STATIC_ASSERT;EIGEN_NO_STATIC_ASSERT
--  GTSAM_COMPILE_OPTIONS_PUBLIC_DEBUG               :
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_DEBUG           :
--  GTSAM_COMPILE_OPTIONS_PUBLIC_RELEASE             :
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELEASE         :
--  GTSAM_COMPILE_OPTIONS_PUBLIC_TIMING              :
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_TIMING          :
--  GTSAM_COMPILE_OPTIONS_PUBLIC_PROFILING           :
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_PROFILING       :
--  GTSAM_COMPILE_OPTIONS_PUBLIC_RELWITHDEBINFO      :
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_RELWITHDEBINFO  :
--  GTSAM_COMPILE_OPTIONS_PUBLIC_MINSIZEREL          :
--  GTSAM_COMPILE_DEFINITIONS_PUBLIC_MINSIZEREL      :
--  Use System Eigen                                 : OFF (Using version: 3.3.7)
--  Use System Metis                                 : OFF
--  Using Boost version                              : 107200
--  Use Intel TBB                                    : TBB not found
--  Eigen will use MKL                               : MKL not found
--  Eigen will use MKL and OpenMP                    : OpenMP found but GTSAM_WITH_EIGEN_MKL is disabled
--  Default allocator                                : STL
--  Cheirality exceptions enabled                    : YES
-- Packaging flags
--  CPack Source Generator                           : TGZ
--  CPack Generator                                  : TGZ
-- GTSAM flags
--  Quaternions as default Rot3                      : Disabled
--  Runtime consistency checking                     : Disabled
--  Rot3 retract is full ExpMap                      : Enabled
--  Pose3 retract is full ExpMap                     : Enabled
--  Allow features deprecated in GTSAM 4.1           : Enabled
--  Metis-based Nested Dissection                    : Enabled
--  Use tangent-space preintegration                 : Enabled
-- MATLAB toolbox flags
--  Install MATLAB toolbox                           : Disabled
-- Python toolbox flags
--  Build Python module with pybind                  : Disabled
-- ===============================================================
CMake Warning at cmake/HandleFinalChecks.cmake:3 (message):
  TBB 4.4 or newer was not found - this is ok, but note that GTSAM
  parallelization will be disabled.  Set GTSAM_WITH_TBB to 'Off' to avoid
  this warning.

Expected behavior

It should not segfault.

Environment

MSVC2019 v16, CMake 3.23, Boost 1.72, no TBB, Eigen3 shipped with GTSAM

Additional information

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions