-
Notifications
You must be signed in to change notification settings - Fork 28
how to debug the segfaults
From PR #109 by @yosefm
After spending like 2 hours with Lily trying to find why his Mac trips code that works perfectly fine on Linux, we tracked it again to a memory access violation that just didn't cause trouble on Linux and did on Mac.
Beside fixing this one bug, I also used the Electric Fence tool to consistently trip memory access bugs. To use it, pass -DCMAKE_BUILD_TYPE=Debug
to Cmake. The tool links his own memory allocator to the library, so we don't want it in release builds.
So, With this I added a test to trip the bug in segmentation, fixed it, and fixed one more that efence found.
Add on for Mac users from @alexlib
Mac users can download the Mac version of Electric Fence here memory debuggers, see at the bottom the compressed folder bz2 after expanding, probably best to change the installation library (at least that's what I had to do on my Mac:
open `Makefile` and change line 8 to:
LIB_INSTALL_DIR= /usr/local/lib
Then it's just
sudo make
that did the installation for me.
then I could compile with the memory debugger as it's suggested:
cd liboptv
mkdir build && cd build
cmake --DCMAKE_BUILD_TYPE=Debug ../
make verify
sudo make install