gpt4 book ai didi

c - stack smashing后报错信息怎么办

转载 作者:IT王子 更新时间:2023-10-29 01:02:50 24 4
gpt4 key购买 nike

我的 C 程序在 Linux 上遇到了一些问题。它在 Windows 上编译和运行得很好。 Linux 终端返回此信息:

*** stack smashing detected ***: ./student terminated       
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x4b)[0xb7e908ab]
/lib/libc.so.6(__fortify_fail+0x0)[0xb7e90860]
./student[0x8048c09]
./student[0x80486dd]
/lib/libc.so.6(__libc_start_main+0xe5)[0xb7dc0775]
./student[0x80485e1]
======= Memory map: ========
08048000-0804a000 r-xp 00000000 00:11 11222 /mnt/win/POT03/Eclipse/student
0804a000-0804b000 r--p 00001000 00:11 11222 /mnt/win/POT03/Eclipse/student
0804b000-0804c000 rw-p 00002000 00:11 11222 /mnt/win/POT03/Eclipse/student
0804c000-0821a000 rw-p 0804c000 00:00 0 [heap]
b7da9000-b7daa000 rw-p b7da9000 00:00 0
b7daa000-b7eeb000 r-xp 00000000 75:00 116292 /lib/libc-2.9.so
b7eeb000-b7eed000 r--p 00141000 75:00 116292 /lib/libc-2.9.so
b7eed000-b7eee000 rw-p 00143000 75:00 116292 /lib/libc-2.9.so
b7eee000-b7ef1000 rw-p b7eee000 00:00 0
b7ef4000-b7f01000 r-xp 00000000 75:00 116275 /lib/libgcc_s.so.1
b7f01000-b7f02000 r--p 0000c000 75:00 116275 /lib/libgcc_s.so.1
b7f02000-b7f03000 rw-p 0000d000 75:00 116275 /lib/libgcc_s.so.1
b7f03000-b7f06000 rw-p b7f03000 00:00 0
b7f06000-b7f22000 r-xp 00000000 75:00 116288 /lib/ld-2.9.so
b7f22000-b7f23000 r--p 0001b000 75:00 116288 /lib/ld-2.9.so
b7f23000-b7f24000 rw-p 0001c000 75:00 116288 /lib/ld-2.9.so
bf8eb000-bf900000 rw-p bf8eb000 00:00 0 [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
Aborted

我可以用这些信息做什么来追踪问题?

最佳答案

使用调试信息编译您的程序,然后使用 valgrind 运行。

gcc -g student.cpp -o student
valgrind ./student

尝试调试器:

gcc -g student.cpp -o student
gdb ./student
run
// wait for it to crash
backtrace
help // to figure out what else you can do

关于c - stack smashing后报错信息怎么办,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2307233/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com