-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GTSAM segfault on noiseModel::Diagonal::Sigmas #75
Comments
The error says it can't find malloc.h which is a std library. This seems like a linker error on your system. Can you please verify that gcc can see the path to /usr/include? |
Yes, I have no problem running gtsam on my original project using build c844966. It occurs to me when I switch to the newest commit. I will try to bisect the commit once I get back to my computer. |
Try disabling march=native.
Not a real solution, but will help to confirm a usual suspect...
|
Disabling march=native works. Thanks! Just a bit curious why it doesn't work.. |
Still not 100% clear, so I think this one should remain open ;-) Probably it's caused by different flags while compiling different sources/projects that use Eigen... PS: It seems it's a custom project... Please, try to create the minimum CMakeLists.txt + main.cpp that fails to reproduce the problem. |
I'm facing the exact same issue here. I somehow managed to build the simplest example to show the segfault NOTE: This same example does not crash with this version c844966 , but rather with <4.0.0>. This could be a starting point to find where is the issue CMakeLists.txt # ~~~
# @file CMakeLists.txt
# @author Ignacio Vizzo [[email protected]]
#
# Copyright (c) 2019 Ignacio Vizzo, all rights reserved
cmake_minimum_required(VERSION 3.10)
project(gtsam_crash)
find_package(GTSAM REQUIRED)
include_directories(${GTSAM_INCLUDE_DIRS})
add_executable(crash_test main.cpp)
target_link_libraries(crash_test gtsam) And the example program: // @file main.cpp
// @author Ignacio Vizzo [[email protected]]
//
// Copyright (c) 2019 Ignacio Vizzo, all rights reserved
#include <gtsam/geometry/Pose3.h>
#include <gtsam/linear/NoiseModel.h>
#include <gtsam/nonlinear/NonlinearFactor.h>
#include <gtsam/slam/BetweenFactor.h>
#include <Eigen/Core>
int main() {
auto model =
gtsam::noiseModel::Gaussian::Information(Eigen::Matrix3d::Identity());
gtsam::NonlinearFactor::shared_ptr factor(
new gtsam::BetweenFactor<gtsam::Pose3>(0, 0, gtsam::Pose3(), model));
return 0;
} With the following traceback to the crash Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x20) at malloc.c:3103
3103 malloc.c: No such file or directory.
(gdb) bt
#0 __GI___libc_free (mem=0x20) at malloc.c:3103
#1 0x00007ffff7829d2c in gtsam::noiseModel::Diagonal::Sigmas(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, bool) () from /usr/local/lib/libgtsam.so.4
#2 0x00007ffff7660c34 in _GLOBAL__sub_I_lago.cpp () from /usr/local/lib/libgtsam.so.4
#3 0x00007ffff7de5733 in call_init (env=0x7fffffffd7b8, argv=0x7fffffffd7a8, argc=1, l=<optimized out>) at dl-init.c:72
#4 _dl_init (main_map=0x7ffff7ffe170, argc=1, argv=0x7fffffffd7a8, env=0x7fffffffd7b8) at dl-init.c:119
#5 0x00007ffff7dd60ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000001 in ?? ()
#7 0x00007fffffffdc69 in ?? ()
#8 0x0000000000000000 in ?? () |
I've found a simpler example that also segfaults on version 4.0.0 but not on c844966 (the backtrace is exactly the same) // @file main.cpp
// @author Ignacio Vizzo [[email protected]]
//
// Copyright (c) 2019 Ignacio Vizzo, all rights reserved
#include <gtsam/slam/BetweenFactor.h>
int main() { auto factor(new gtsam::BetweenFactor<double>(1, 2, 0.0)); } |
Thank you @nachovizzo, these are super helpful. We'll investigate this ASAP. |
Thanks @nachovizzo for the test! I can't reproduce the crash... my settings are:
It doesn't fail in any of those two settings. Please, report the outputs from:
Also, just for curiosity, try if using libgtsam-dev from the PPA repository does also crash. Note that after installing, you will have to either uninstall it, or explicitly set GTSAM_DIR= to get back to use your own local build of the library, naturally. |
Just to add more information to this. If both |
That's really relevant, thanks @ke-sun ! However was able to bypass this exported flag, please share with us how did you include gtsam into your project, since the current Regarding the opening issue report above, if nobody manages to reproduce the crash, I think this one could be closed after some prudent time. |
@jlblancoc |
FWIW I am also getting this same issue. Here's the stacktrace from gdb for me:
|
Hi @fishyai , What are your settings? A minimal set of PS: Recently I found a crash very similar to this one, and it turned out the problem was using different GCC versions (5 vs 7) for gtsam and my project, and enabling the native optimization. Avoiding those two solved the issue, but I would be happier with a better understanding of what exactly is the "MUSTN'T DO"... |
I think it's related to your explanation above. I was trying to include GTSAM and DART in the same project: https://dartsim.github.io/. I'm guessing it has something to do with different Eigen settings. All I did was link the two libraries into another project and include a header from both in the same file. That was enough to cause the error. I can make a Docker example to show, but probably won't get to it for a couple weeks. Thanks for your help! |
Can we close this? |
disable 'march=native' works for me, reference https://github.com/borglab/gtsam/pull/4/files |
This issue is still relevant with "4.0.3 release". Disabling "march=native" solves it. |
Note to all future visitors: if two of your dependencies use Eigen, make sure they are using the same version and use the same compilation settings. This is an inherent issue with a header-only library (Eigen) and is in no way related to GTSAM. NOTE: it is irrelevant whether you are using a dynamic library. Eigen with different settings = FAIL. There is a flag in GTSAM that makes GTSAM use the system Eigen. If you link other projects and GTSAM at the same time, make sure that you enable this. |
5ddaff8ba Merge pull request #77 from borglab/fix/template-as-template-arg 0b6f2d92b allow templates as paramters to templates 7f3e242b0 Merge pull request #76 from borglab/fix/cmake-config 0caa79b82 macro to find and configure matlab 522557232 fix GTWRAP_INCLUDE_NAME 78a5d3afa Use CMakePackageConfigHelpers to vastly simplify the package config 76f8b9e5d Merge pull request #75 from borglab/fix/template-args 3b8e8389e remove reference from shared pointers 045393c7b docs and flag renaming d23d8beae tests ef96b4bdc don't make template parameters as references d1e1dc697 Merge pull request #74 from borglab/fix/type-recursion 8202ecf10 minor fixes 5855ea85b support for passing templated types as arguments 150cc0578 Support for templated return types 5c58f8d03 Merge pull request #73 from borglab/fix/types-refactor c697aa9c8 refactored the basic and custom types to make it cleaner, added more tests 98e2c3fa1 Merge pull request #68 from borglab/fix/cmake c6d5e786a make config agnostic to install prefix 4d6999f15 Merge pull request #69 from borglab/feature/call-and-index ccf408804 add support for callable and indexing overloads 8f8e3ec93 add status messages 88566eca4 make WRAP_PYTHON_VERSION an optional argument 01b8368ad Merge pull request #67 from borglab/feature/operator-overloading 522a12801 remove unsupported operators 209346133 update check location for unary operator 39e290f60 fix small typo faa589bec update DOCS 7ff83cec8 minor fixes 8ce37766f fixed tests 21c477c4d include pybind11/operators a3534ac5e wrap operator overloads 67c8f2089 instantiate templates for operators e9dce65d8 use ReturnType for ease in other places and use members in Class 3078aa6db added parser rule for operator overloading git-subtree-dir: wrap git-subtree-split: 5ddaff8bab6c05e8a943c94993bf496e13296dd6
Note on the "disable I've found that enabling To enable add_compile_options("-march=native") to your main CMakeLists.txt. This is still a workaround, since it seems GTSAM should be adding this compile option to any dependent project according to #75 (comment), but this doesn't seem to always work. |
Hi,
Please, if you could put together a minimal example of where a build of gtsam with march=native enabled does not propagate the flag to a client project, it would be great for debugging the issue. Thanks. |
added compile option native , ![ref](borglab/gtsam#75)
Hi @jlblancoc, Note, in this case I include the dependent packages only by using |
Hi @nubertj First, if your problem is because of using the march-native flag while building GTSAM, try disabling it and rebuild eveything to see if everything works first. That flag may add some performance gain, but it's probably not worth the problems in early prototyping stages. And if you are using ROS 1 (as it seems from you mentioning catkin), let's hope this PR I made yesterday is accepted in time for GTSAM binary packages to get published directly by ROS 1 buildfarm, so all you would need to do is |
Dear @jlblancoc,
I am using GTSAM and catkin for two years on a regular basis, and all works perfectly fine without march=native Now I tried it again after some time to potentially get a small speedup boost, but I get the above-mentioned issues. I even set all the build flags in EVERY library down the line that are either directly or indirectly depending on GTSAM or any of the intermediate libraries. But still, the same issue persists...
This is the case, we build GTSAM always with the system eigen. Meanwhile, I am just using GTSAM still without march native, all good. |
Just migrated from bitbucket repo commit c844966 to github newest version. GTSAM segfaults on running the code. GDB backtrace shows
However, I have no problem in the build c844966. Built with TBB enabled, MKL disabled, and using system Eigen. I tried both using system Eigen and using package Eigen, but none of them works. Would appreciate any help!
The text was updated successfully, but these errors were encountered: