rosieblue
article thumbnail
Published 2024. 4. 13. 14:56
core file 분석 (수정중) Etc
728x90

 

일단 아래 명령어를 실행해서 core 파일의 크기 제한을 없앤다.

ulimit -c unlimited

 

 

 

코어 파일 생성 위치

보통은 프로세스 있는 디렉토리에 생성된다

하지만 나는 커멘드를 실행했을 때 커멘드가 죽는 경우여서 ㅎ...

 

 

/proc/sys/kernel/core_pattern을 읽어보면 corefile이 어떤 규칙으로 생성되는지 알 수 있다 

odroid@odroid:/var/lib/systemd/coredump$ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E

코어파일 생성 따로 안하고 그냥 stdin 인풋으로 코어 내용을 apport에 전달하는 것 같다

이거 수정가능한가..?

아니 근데 오드로이드만 왜 이따군데;; 여기서 분석해야하느데ㅜㅜ

 

hnkim@eagle:~$ cat /proc/sys/kernel/core_pattern
core

이건 걍 코어파일이 core로 생성된다는 뜻 ㅎ

 

haeun@DESKTOP-8NK4D08:~$ cat /proc/sys/kernel/core_pattern
/mnt/wslg/dumps/core.%e

이거는 /mnt/wslg/dumps/core.%e 형식으로 생성된다는 뜻 (%e는 프로세스 이름)

 

 

아래 스택오버플로우에 너무너무 잘 설명되어있다....

https://stackoverflow.com/questions/2065912/core-dumped-but-core-file-is-not-in-the-current-directory  

 

Core dumped, but core file is not in the current directory?

While running a C program, It says "(core dumped)" but I can't see any files under the current path. I have set and verified the ulimit: ulimit -c unlimited ulimit -a I also tried to find a file

stackoverflow.com

 

아니근데 오드로이드 환경에서는 abrt 디렉토리가 없었던 거 같은데ㅜ ㅜ 월요일에 출근해서 다시 살펴봐야겠다 사수님이 나를 개 한심해하시는게 보인다 진짜 이번에 못고치면 잣댈듯

 

 

 

결국 아래처럼 그냥 core_pattern 파일을 수정했다

 

참고로 꼭 루트 계정으로 해야하며(sudo는 안 될 수도 있음), 곧바로 vi ~~~/core_pattern 이렇게 수정하면 또 안 됐다ㅠㅠ (안 그러면 "/proc/sys/kernel/core_pattern" e667: fsync failed 에러가 뜬다)

위처럼 echo로 해주니까 수정이 가능했다!

 

 

gdb로 core file 분석

https://blog.naver.com/PostView.nhn?blogId=njuhb&logNo=220983631282

 

gdb를 이용한 core 파일분석

1. core dump 파일을 남기는지 확인 ulimit -a 명령 실행 core file size 항목이 설정되 있는 경우 가능 없...

blog.naver.com

https://csj000714.tistory.com/626

 

[Linux] gdb로 core dump 파일 디버깅하는 방법(feat. load core dump)

💡 본 문서는 'gdb로 core dump 파일 분석하는 방법'에 대해 정리해놓은 글입니다. 열심히 키워놓은 프로그램이 어느 날 갑자기 죽거나 hang 걸리며 뻗어버리는 모습을 볼 때가 있습니다. 일반적으로

csj000714.tistory.com

 

profile

rosieblue

@Rosieblue

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!