[dmesg] segfault
1. segfault 의미
- segmentation fault
- the application is trying to access a memory area that belongs to the OS or some other program. The memory management unit in the CPU stops the operation and triggers an exception. The standard segfault exception handler in the kernel kills the program.
- the program probably tried to use an uninitialized pointer, which has a value NULL
2. segfault 예
- scagent[1569]: segfault at 7f2ecca29fc8 ip 00000039ff64432a sp 00007f2ecca29fd0 error 6 in libc-2.12.so[39ff600000+18a000]
- epi_alert_svr[26620]: segfault at 0 ip 00000000004142db sp 00002af6e33efd20 error 4 in epi_alert_svr[400000+1c000]
3. segfault 원인
- 잘못된 메모리 공간에 쓰기 시도(허용되지 않은 메모리 영역에 접근을 시도, 허용되지 않은 방법으로 메모리 영역에 접근을 시도). 예를 들어, 읽기 전용 영역에 어떤 내용을 쓰려고 시도하거나, 운영 체제에서 사용하는 영역에 다른 내용을 덮어쓰려 하는 경우
- 메모리 문제
- 하드디스크에 배드 섹터가 있어도 발생
- 개발 소스 아키텍처 관련 문제
4. segfault 항목의 의미
- ip(rip): instruction pointer. ie. where the code which is trying to do this lives
- sp(rsp): stack pointer
- at: address. (it's likely that 10 and 11 are offsets from a pointer we expect to be set to a valid value but which is instead pointing to 0)
- error: value of page fault error code, ie. last error code which was reported by a syscall
- [39ff600000+18a000]: starting address and size of virtual memory area where offending object was mapped at the time of crash
5. segfault error 넘버의 의미
- 4: The cause was a user-mode read resulting in no page being found.(also known as a null pointer dereference)
4 is EINTR (interrupted system call)
- 6: The cause was a user-mode write resulting in no page being found.
6. segfault 조치 방법
If possible, have your application developer produce a version of the application that includes debug information. If the application is compiled using gcc, this is as simple as adding the "-g" option to the compilation commands.
Before starting the application, run "ulimit -c unlimited". This allows the segfault handler to produce a core dump file when the segfault handler is triggered. This file contains all the memory used by the application, so it might be very big.
Then your application developer needs to run a debugger program on the application and the core file. If the application was compiled with debug information, the debugger can identify exactly on what line of the source code the error happened. The developer can also use the debugger to examine the values of any variables at the time of the error. The debugger has many other features which might be useful too. If your developer does not know how to use a debugger, he/she should definitely learn it.
For Linux, the most common debugger program is named "gdb" and it is available in most Linux distributions. It is usually in the "development tools" category of the distribution's package collection.
7. 참조 URL
- http://rgeissert.blogspot.kr/2013/07/explaining-segmentation-fault-errors.html
- http://rgeissert.blogspot.kr/p/segmentation-fault-error.html
- http://stackoverflow.com/questions/2549214/interpreting-segfault-messages
- http://adnoctum.tistory.com/387