Segmentation fault at mbl_mw_metawearboard_tear_down

Hi,

Sometimes, I have a segmentation fault when closing ble connections with the board.

- MetaMotion R board, firmware version 1.3.3.
- Metawear C++ API 0.7.14

My scenario consists on a Linux PC connecting two boards with a high rate streaming accelerometer, magnetometer and gyroscope.

The big issue is that I do not have any information about what is failing during the tear_down.

I have compiled the debug version of the shared library but cannot read debugging info (I am currently debugging other libaries with no problem). Is there something more I have to do to debug metawear library?

(gdb) info shared
From                To                  Syms Read   Shared Object Library
0x00007ffff7dd7ac0  0x00007ffff7df5640  Yes         /lib64/ld-linux-x86-64.so.2
0x00007ffff7bcca60  0x00007ffff7bd193c  Yes         ../sensoring/libsensoring.so
0x00007ffff7926d20  0x00007ffff7983420  Yes (*)     ../metawear/libmetawear_d.so.0
[. . .]
0x00007ffff70ff860  0x00007ffff71767b9  Yes (*)     /lib/x86_64-linux-gnu/libglib-2.0.so.0
0x00007ffff6ecda30  0x00007ffff6edaa51  Yes         /lib/x86_64-linux-gnu/libpthread.so.0
0x00007ffff6bcfd20  0x00007ffff6c7bcc9  Yes (*)     /usr/lib/x86_64-linux-gnu/libstdc++.so.6
0x00007ffff6932a70  0x00007ffff69428b5  Yes (*)     /lib/x86_64-linux-gnu/libgcc_s.so.1
0x00007ffff65868b0  0x00007ffff66d8f14  Yes         /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff6263600  0x00007ffff62d4d0a  Yes         /lib/x86_64-linux-gnu/libm.so.6
0x00007ffff5fef530  0x00007ffff603e623  Yes (*)     /lib/x86_64-linux-gnu/libpcre.so.3
(*): Shared library is missing debugging information.

This is the backtrace when the segmentation fault occurs:

0x00007ffff792bbf8 in std::__shared_ptr<void, (__gnu_cxx::_Lock_policy)2>::get() const () from ../metawear/libmetawear_d.so.0
(gdb) bt
#0  0x00007ffff792bbf8 in std::__shared_ptr<void, (__gnu_cxx::_Lock_policy)2>::get() const () from .../metawear/libmetawear_d.so.0
#1  0x00007ffff7971f37 in mbl_mw_metawearboard_tear_down () from ../metawear/libmetawear_d.so.0
[. . .]

Issue is in this call (but I am no using logging):
 tear_down_logging(board->logger_state.get(), true);

Summarizing:

- How can I have information about what is failing during the tear_down?
- Is there something more I have to do in order to debug metawear library?
- Is there someting I can do to avoid the issue?

Thanks in advance,
Marc


Comments

  • Place a breakpoint at mbl_mw_metawearboard_tear_down and check that board and logger_state are still pointing to valid addresses. The debug build compiles the shared library with the "-g" flag.

    When are you calling mbl_mw_metawearboard_tear_down in your code?  Are you perhaps calling it after mbl_mw_metawearboard_free?
  • Hi Eric,

    Thanks for the quick answer. It was my fault. I had a dangling pointer and board was already invalid when I called tear down.

    However, I could not debug the library compiled with the debug flag "-g". It seems that library don't have debugging symbols. Do you know if there is something I should do in addition to the debug flag?
  • Check out the latest commit to the C++ SDK.
  • Hi Eric,

    Debug is now working with this last commit.

    Many thanks!
This discussion has been closed.