Ubuntu 16.04: Matlab crashes when executing VisualISAMExample

Issue #310 new
Martin Rünz created an issue

What:

Matlab crashes when executing the VisualISAMExample example. I discovered that the crash occurs when an exception is thrown within p = values.atPoint3(key) [Line 23 of .../gtsam_toolbox/+gtsam/plot3DPoints.m].

More specifically, it occurs when returning from the function _defaultKeyFormatter, so I think it is related to a destructor (or maybe copy constructor) call. I noticed that the crash vanishes when the casting from Symbol to string is avoided.

Fix:

Using the following implementation to cast from a Symbol to a string fixes the crash on my system:

#include <sstream>

Symbol::operator std::string() const {
    std::stringstream ss;
    ss << c_ << j_;
    return ss.str();
}

Instead of:

Symbol::operator std::string() const {
  return str(boost::format("%c%d") % c_ % j_);
}

I can't say, however, why the original implementation triggers a crash. Any ideas?

Stack Trace (from fault):

[  0] 0x00007faef9927428                    /lib/x86_64-linux-gnu/libc.so.6+00218152 gsignal+00000056
[  1] 0x00007faef992902a                    /lib/x86_64-linux-gnu/libc.so.6+00225322 abort+00000362
[  2] 0x00007faef99697ea                    /lib/x86_64-linux-gnu/libc.so.6+00489450
[  3] 0x00007faef9971e0a                    /lib/x86_64-linux-gnu/libc.so.6+00523786
[  4] 0x00007faef997598c                    /lib/x86_64-linux-gnu/libc.so.6+00539020 cfree+00000076
[  5] 0x00007fad8c7d7493                       /usr/local/lib/libgtsam.so.4+01524883 _ZNK5gtsam6SymbolcvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev+00000355
[  6] 0x00007fad8c7d370b                       /usr/local/lib/libgtsam.so.4+01509131 _ZN5gtsam20_defaultKeyFormatterB5cxx11Em+00000331
[  7] 0x00007fad8d235e60      /usr/local/gtsam_toolbox/gtsam_wrapper.mexa64+06262368 _ZN5boost6detail8function17function_invoker1IPFNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmES8_mE6invokeERNS1_15function_bufferEm+00000032
[  8] 0x00007fad8c8d3a80                       /usr/local/lib/libgtsam.so.4+02558592 _ZNK5gtsam19ValuesIncorrectType4whatEv+00000304
[  9] 0x00007fad8d2226e7      /usr/local/gtsam_toolbox/gtsam_wrapper.mexa64+06182631 mexFunction+00000247
[ 10] 0x00007faeeb3b5caa     /usr/local/MATLAB/R2016b/bin/glnxa64/libmex.so+00175274 mexRunMexFile+00000106

How to reproduce:

  • Start matlab, here:
   cd /path/to/gtsam/matlab/gtsam_examples
   env LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab
  • Run example, here:
   addpath('/usr/local/gtsam_toolbox')
   VisualISAMExample

System:

  • Operating system: Ubuntu 16.04.1 LTS
  • Compiler: gcc version 5.4.0
  • Matlab: 2016b

Comments (2)

  1. Log in to comment