程序运行出现段错误:
![](https://img-blog.csdnimg.cn/img_convert/e8a5d63756bcab253d4fc57121b88b82.png)
解决步骤:
首先使用下面的指令,查看core文件的大小,看有没有设置core文件的大小。
ulimit -a
![](https://img-blog.csdnimg.cn/img_convert/12a4837daca0d9269e72276a4ad4f997.png)
2.设置core文件的大小为unlimited(无限制)或者其他大小,如100
指令:
ulimit -c unlimited
查看设置后的大小:
![](https://img-blog.csdnimg.cn/img_convert/012f53c207f75510f9527a17815d7728.png)
这时候我们设置完了core文件的大小
3.查看core文件的存在位置
cat /proc/sys/kernel/core_pattern
![](https://img-blog.csdnimg.cn/img_convert/6be755100c76d7e5293558f8bdaca20e.png)
上述结果表明,core文件会被Linux的apport进程处理掉。
4.我们可以通过关闭apport这个进程来产生core文件
sudo service apport stop
[sudo] nowcoder 的密码:
5.编译运行文件
nowcoder@nowcoder:~/Linux/lesson26$ gcc core.c -g
nowcoder@nowcoder:~/Linux/lesson26$ ./a.out
6.查看当前目录,发现产生了core文件
![](https://img-blog.csdnimg.cn/img_convert/566ec16b8e32652cb963fae83b392cf1.png)