简体   繁体   中英

Unable to identify reasons for signal SIGSEGV, Segmentation fault

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.

在此处输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM