Reputation: 652
I am running a cpp program in ubuntu. I am getting a signal SIGSEGV, Segmentation fault.
I tried to use gdb to see the exact line for segmentation fault. I get this idea from this thread of question:
Determine the line of code that causes a segmentation fault?
The gdb is returning me this:
Thread 1 "incremental_sat" received signal SIGSEGV, Segmentation fault.
0x00007ffff7857c50 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
Please see the screenshot of the terminal below:
I am using data structure involving all types of vector and unordered_map for int and string.
Can I know, which all lines of code is responsible for this error?
I am new to debugging in CPP. Any suggestion for the direction I can proceed with this info?
UPDATE: after the suggestion of running "bt" command, I am adding the output:
I am observing that it is getting segmentation fault just after calling cnf_transformation_out_diff() function. As it is not even printing the first cout command written in cnf_transformation_out_diff() function.
Upvotes: 0
Views: 1626
Reputation: 652
Finally, I resolved the bug with the help of my friend Arpan.
In one scenario, the data structure gates_out_diff remained empty. I didn't added the safety check and the program is accessing the gates_out_diff[i][1] value, so it resulted in a segmentation fault.
It is running after I fixed that case. It took me one day. Hope it saves someone's time.
Upvotes: 0