Linux 编程段错误(segmentation error)总结
最近一段时间在linux下用C做一些学习和开发,但是由于经验不足,问题多多。而段错误就是让我非常头痛的一个问题。不过,目前写一个一千行左右的代码,也很少出现段错误,或者是即使出现了,也很容易找出来,并且处理掉。
那什么是段错误?段错误为什么是个麻烦事?以及怎么发现程序中的段错误以及如何避免发生段错误呢?
一方面为了给自己的学习做个总结,另一方面由于至今没有找到一个比较全面介绍这个虽然是“particular problem”的问题,所以我来做个抛砖引玉吧。下面就从上面的几个问题出发来探讨一下“Segmentation faults"吧。
目录
1。什么是段错误?
2。为什么段错误这么“麻烦”?
3。编程中通常碰到段错误的地方有哪些?
4。如何发现程序中的段错误并处理掉?
正文
1。什么是段错误?
下面是来自Answers.com的定义:
Quote:
A
segmentation fault (often shortened to segfault) is a particular error
condition that can occur during the operation of computer software. In
short, a segmentation fault occurs when a program attempts to access a
memory location that it is not allowed to access, or attempts to access
a memory location in a way that is not allowed (e.g., attempts to write
to a read-only location, or to overwrite part of the operating system).
Systems based on processors like the Motorola 68000 tend to refer to
these events as Address or Bus errors.
Segmentation is one
approach to memory management and protection in the operating system.
It has been superseded by paging for most purposes, but much of the
terminology of segmentation is still used, "segmentation fault" being
an example. Some operating systems still have segmentation at some
logical level although paging is used as the main memory management
policy.
On Unix-like operating systems, a process that accesses
invalid memory receives the SIGSEGV signal. On Microsoft Windows, a
process that accesses invalid memory receives the
STATUS_ACCESS_VIOLATION exception.
另外,这里有个基本上对照的中文解释,来自http://www.linux999.org/html_sql/3
相关文档:
#pacman -S openssh #安装openssh
安装完成后在/etc/rc.conf的最底部DAEMONS后添加sshd让系统启动时自动启动openssh
DAEMONS=(syslog-ng network netfs crond sshd)
也可手动启动openssl,执行
#/etc/inin.d/sshd start
默认情况下其它电脑是不能通过ssh来访问archlinux的,需要修改两个文件来实现:
/etc/h ......
在上篇文章的结尾,我们说会在接下来的文章分析分配函数的具体代码,结合我上篇文章说的伙伴机制和冷热区的概念,更好得去理解这个分配过程。好了,我们不再多说了,我们现在开始分析代码吧。
struct page * fastcall __alloc_pages(unsigned int gfp_mask, unsigned int order,struct zonelist *zonelist)
......
phpMyAdmin提示没字符串编码和字符串处理库php_mbstring
SSH连接上后:yum install php-mbstring安装扩展
vi usr/local/lxlabs/ext/php/etc/php.ini编辑PHP.ini文件
去掉一行的注释:extension=mbstring.so
(有些可以不用设置这两行,php.ini中不存在;extension=mbstring.so
,
只要mbString扩展安装到了extension ......
http://linux.chinaitlab.com/administer/774036.html
[ 起源 ]Linux/Unix下守护进程(Daemon)大家都知道,比如我们常用的httpd、mysqld等等,就是常驻内存运行的程序,类似于Windows下的服务。一般守护进程都是使用C/C++来写,就是通过fork生成子进程,当前台shell下的父进程被杀掉,子进程就转到后台运行,为了不 ......