主返回后段错误 [英] segmentation fault after main returns
问题描述
我在c在Linux的长期计划,这给了我主返回后段故障。
它是一种长的节目,所以我不能将它张贴。所以,你能帮我什么都能做这样的错误?
I have a long program in c over Linux, that gives me segmentation fault after main returns. Its a long program, so I cant post it. So can you help me what can make such error?
感谢你。
哇,这些问题的答案来的真快。谢谢大家。
我觉得我的工作了,我忘了到malloc的字符串,并用它作为缓冲。
现在,我已经malloced它,它并不意味着我一个分段错误。
Wow, Those answers came really fast. Thank you all. I think i worked it out, i forgot to malloc a string and used it as buffer. Now that I've malloced it, it does not signal me with a segmentation fault.
再一次谢谢大家。
推荐答案
猜测:所以它的返回地址丢失,你可能会不小心破坏了堆栈主。你有一个字符串缓冲区那里,你可能会被超越?
Guess: you might be accidentally corrupting the stack in main so it's lost the return address. Do you have a string buffer there that you could be overrunning?
如果没有,你应该试试:
If not, you should try:
- 在Valgrind的运行程序
- 用gdb调试程序赶上大跌,看看你是在这一点;您还可以调试核心文件抛投
这可能有助于安装的glibc-调试包,如果你的发行版有他们,因为你会在这一点的glibc code。
It might help to install glibc-debug packages if your distro has them since you'll be in glibc code at that point.
这篇关于主返回后段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!