Segmentation fault at mbl_mw_metawearboard_tear_down


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/
0x00007ffff7bcca60  0x00007ffff7bd193c  Yes         ../sensoring/
0x00007ffff7926d20  0x00007ffff7983420  Yes (*)     ../metawear/
[. . .]
0x00007ffff70ff860  0x00007ffff71767b9  Yes (*)     /lib/x86_64-linux-gnu/
0x00007ffff6ecda30  0x00007ffff6edaa51  Yes         /lib/x86_64-linux-gnu/
0x00007ffff6bcfd20  0x00007ffff6c7bcc9  Yes (*)     /usr/lib/x86_64-linux-gnu/
0x00007ffff6932a70  0x00007ffff69428b5  Yes (*)     /lib/x86_64-linux-gnu/
0x00007ffff65868b0  0x00007ffff66d8f14  Yes         /lib/x86_64-linux-gnu/
0x00007ffff6263600  0x00007ffff62d4d0a  Yes         /lib/x86_64-linux-gnu/
0x00007ffff5fef530  0x00007ffff603e623  Yes (*)     /lib/x86_64-linux-gnu/
(*): 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/
(gdb) bt
#0  0x00007ffff792bbf8 in std::__shared_ptr<void, (__gnu_cxx::_Lock_policy)2>::get() const () from .../metawear/
#1  0x00007ffff7971f37 in mbl_mw_metawearboard_tear_down () from ../metawear/
[. . .]

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


- 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,


  • 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.