1.步骤:
gdb ./your_program
run
bt # 查看崩溃时的调用栈
输出示例:
#0 0x00007ffff7e8f1a7 in std::__throw_logic_error (__s=0x7ffff7f9b8d8 "basic_string::_M_construct null not valid")
#1 0x00005555555552b9 in std::string::_M_construct<char const*> (this=0x7fffffffd9f0, __beg=0x0, __end=0x0, ...)
#2 0x00005555555551c6 in main () at your_code.cpp:10
#2 显示崩溃发生在 main() 函数的 your_code.cpp:10(第 10 行)。
__beg=0x0 表明传入的指针是 nullptr。
浙公网安备 33010602011771号