RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.35k stars 1.27k forks source link

Bus error / abort trap related to Eigen usage under Xcode 11 #12107

Closed jamiesnape closed 5 years ago

jamiesnape commented 5 years ago

Appears to be in release configuration only. One such failure relates to this line: https://github.com/RobotLocomotion/drake/blob/7d672344d45d8badd94b5bc76a47b138532c7bba/math/continuous_algebraic_riccati_equation.cc#L24

)$ clang -v
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ bazel test //math:continuous_algebraic_riccati_equation_test

FAIL: //math:continuous_algebraic_riccati_equation_test (see /private/var/tmp/_bazel_user/7c7ad393d9017d670ea6cd4ae3566d69/execroot/drake/bazel-out/darwin-py2-opt/testlogs/math/continuous_algebraic_riccati_equation_test/test.log)
INFO: From Testing //math:continuous_algebraic_riccati_equation_test:
==================== Test output for //math:continuous_algebraic_riccati_equation_test:
Using drake_cc_googletest_main.cc

[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from CARE
[ RUN      ] CARE.TestCare
external/bazel_tools/tools/test/test-setup.sh: line 310: 12507 Bus error: 10           "${TEST_PATH}" "$@" 2>&1
================================================================================

Apparently still an issue using Eigen 3.3.7, but may be fixed in tip. CC #11758.

Blocks macOS Catalina support. CC #11692.

soonho-tri commented 5 years ago

FYI:

jamiesnape commented 5 years ago

Appears to be literally the most recent commit that fixes //math:continuous_algebraic_riccati_equation_test: https://bitbucket.org/eigen/eigen/commits/a5c3d12011a0a8f4b94a44a8b1c5d9139965c812

EricCousineau-TRI commented 5 years ago

\cc @scpeters (just in case this is related to Clang bugs encountered with releasing GMP for Homebrew...)

jamiesnape commented 5 years ago

I think it is related to optimization flags that we see it now, not a bug in the compiler.

jamiesnape commented 5 years ago

(Though I may have a different bug that potentially a libc++ issue. Still triaging that, though.)

soonho-tri commented 5 years ago

A small example (triggering segmentation fault):

// main.cc
#include <iostream>

#include "Eigen/Dense"

int main() {
  Eigen::MatrixXd B(2, 1), R(1, 1);
  B << 0, 1;
  R << 3;
  Eigen::LLT<Eigen::MatrixXd> R_cholesky(R);
  const auto result = R_cholesky.solve(B.transpose())(0, 0);  // Segfault
}
clang++ --std=c++11 -O3 -fstack-check -I <eigen_dir> main.cc
$ clang++ --version
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin