0

I am trying to setup logging using boost in my project and I am spending some time to learn the library. However a simple example, taken from the official tutorial crashes.

#include <boost/log/trivial.hpp>

int main(int, char*[])
{
    BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
    return 0;
}

I am trying to build with CMake using the following commands

g++ -std=c++11 -Wall -pedantic -g -O0 -DBOOST_LOG_DYN_LINK  -c main.cpp 
g++ main.o -lpthread -lboost_log -o main

After compiling and running ./main, I am getting segmentation fault. Why? Is it something wrong with boost log? Did I miss something obvious?

The gdb output might help

Breakpoint 1, main () at main.cpp:6
6       BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
(gdb) n
*** Error in `/home/administrator/lef/bdg3/tests/logging/main': free(): invalid pointer: 0x00007ffff78e11f8 ***

Program received signal SIGABRT, Aborted.
0x00007ffff6cb5267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
55  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
cateof
  • 6,608
  • 25
  • 79
  • 153
  • If you compile it in "Debug" build mode - can be set in ccmake GUI e.g., you can then (provided you're on linux) 'dgb ./main' in command line, in there 'run', and then 'where'. That will give you location of where crash happened with stack trace. – 13ushm4n Oct 04 '16 at 08:36
  • I compiled your code on 64-bit Ubuntu 14.04.4 LTS with 1.55.0 Boost libs installed and got no error. It prints ..."[trace] A trace severity message" which appears to be correct behavior. – 13ushm4n Oct 04 '16 at 08:38
  • I just compiled with debug flags and update my question – cateof Oct 04 '16 at 08:45
  • Do you have ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S file? If not can you locate where the memcpy-sse2-unaligned.S file is located. If you don't have it, is it possible that you have compiled Boost with static linking option? – vordhosbn Oct 04 '16 at 08:59
  • If boost has static linkage, what can I do to run my program? – cateof Oct 04 '16 at 09:06
  • 1
    I don't have the file on my OS. I installed boost libs via 'sudo apt-get install libboost1.55-all-dev' on my Ubuntu, maybe that will work for you as well. – 13ushm4n Oct 04 '16 at 10:28
  • 2
    Could you provide the full backtrace of the crash? As 13ushm4n suggested, it can be obtained by issuing the command `where` or `bt` in gdb. Also, please specify your Boost version. – Andrey Semashev Oct 05 '16 at 11:45

0 Answers0