无法识别信号 SIGSEGV 的原因,分段错误
Unable to identify reasons for signal SIGSEGV, Segmentation fault
我是运行ubuntu中的一个cpp程序。我收到信号 SIGSEGV,分段错误。
我尝试使用 gdb 查看分段错误的确切行。我从这个问题中得到这个想法:
Determine the line of code that causes a segmentation fault?
gdb 返回给我:
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
请看下面的终端截图:
我使用的数据结构涉及所有类型的向量,unordered_map 用于 int 和字符串。
我能知道是哪一行代码导致了这个错误吗?
我是 CPP 调试新手。关于我可以继续使用此信息的方向有什么建议吗?
更新:在 运行 "bt" 命令的建议之后,我添加了输出:
我观察到它在调用 cnf_transformation_out_diff() 函数后出现分段错误。因为它甚至没有打印在 cnf_transformation_out_diff() 函数中编写的第一个 cout 命令。
最后在朋友Arpan的帮助下解决了bug
在一种情况下,数据结构 gates_out_diff 保持为空。我没有添加安全检查,程序正在访问 gates_out_diff[i][1] 值,因此导致了分段错误。
我修复了那个案例后 运行。我花了一天时间。希望它能节省一些人的时间。
我是运行ubuntu中的一个cpp程序。我收到信号 SIGSEGV,分段错误。
我尝试使用 gdb 查看分段错误的确切行。我从这个问题中得到这个想法:
Determine the line of code that causes a segmentation fault?
gdb 返回给我:
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
请看下面的终端截图:
我使用的数据结构涉及所有类型的向量,unordered_map 用于 int 和字符串。
我能知道是哪一行代码导致了这个错误吗?
我是 CPP 调试新手。关于我可以继续使用此信息的方向有什么建议吗?
更新:在 运行 "bt" 命令的建议之后,我添加了输出:
我观察到它在调用 cnf_transformation_out_diff() 函数后出现分段错误。因为它甚至没有打印在 cnf_transformation_out_diff() 函数中编写的第一个 cout 命令。
最后在朋友Arpan的帮助下解决了bug
在一种情况下,数据结构 gates_out_diff 保持为空。我没有添加安全检查,程序正在访问 gates_out_diff[i][1] 值,因此导致了分段错误。
我修复了那个案例后 运行。我花了一天时间。希望它能节省一些人的时间。