Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect where my app collapsed in linux

HI, i am recently in a project in linux written in C. This app has several processes and they share a block of shared memory...When the app run for about several hrs, a process collapsed without any footprints so it's very diffficult to know what the problem was or where i can start to review the codes.... well, it could be memory overflown or pointer malused...but i dunno exactly... Do you have any tools or any methods to detect the problems... It will very appreciated if it get resolved. thanx for your advice...

like image 514
Shaobo Wang Avatar asked Feb 28 '23 17:02

Shaobo Wang


1 Answers

Before you start the program, enable core dumps:

ulimit -c unlimited

(and make sure the working directory of the process is writeable by the process)

After the process crashes, it should leave behind a core file, which you can then examine with gdb:

gdb /some/bin/executable core

Alternatively, you can run the process under gdb when you start it - gdb will wake up when the process crashes.

like image 153
caf Avatar answered Mar 05 '23 16:03

caf