1. Question
I run "crash_demo.run"
by spawn-fcgi
.
How to collect core
file .
2. Background & Environment
I'm exolore C++ Web Programming .
- web-server : nginx
- CGI(FastCGI) : fastcgipp 3.0
- CGI Wrapper : spawn-fcgi
- I didn't use FCGI Wrap which ngifix supplied .
- I understand
FCGI Wrap
be drive by spawn-fcgi , Of course this is off topic .
- My c++ application . (be called
crash_demo
) .
3. Step to reproduce exception
crash_demo
insert codethrow "test exception str, check _core_ file"
, build gotcrash_demo.run
- run nginx :
sudo nginx -c my_nginx_custom.config
ulimit -c unlimited
- run
crash_demo.run
byspawn-fcgi
:spawn-fcgi -a 127.0.0.1 -p 9000 -f /path/crash_demo.run
- test the normal http request , and http request can be completed normally .
- test the
crash_demo
http request , got5xx
response .- The directory where
crash_demo.run
is located does not see thecore
file
- The directory where
My guess
core
file not generate .core
file is generated , but i don't the file path .
Does anyone know what happened?
Solution update
My question is flawed .
Thanks @sehe , my step :
- I read two webpage
- update my
/proc/sys/kernel/core_pattern
core
->core_%e_%p_%t
ulimit -c unlimited
spawn-fcgi -a 127.0.0.1 -p 9000 -f /path/crash_demo.run
sudo find / core_ | grep core_crash_demo
- result
/path/core_crash_demo._5080_1652169152
- result
So , my guess on my question is failed .
The fact is , I don't generate core
file , when my question.
When my generated core
file successed , the core
file path is crash_demo.run
parent directory .
Solution update 2
we whant to know two point :
- how generate core dump file
- how to fine exception code by core dump file
how generate core dump file?
Reference the file : core manual
core manual write many point , I just list the point i care :
- system limit core dump file size , we need unlimit it:
ulimit -a
check limit /ulimit -c unlimited
cancel limit
- fix
/proc/sys/kernel/core_pattern
- default value is
core
- fix it to ->
core_%e_%p_%t
meancore_your_execute_file_name_pid_timestemp
- fix cmd :
sudo bash -c 'echo core_%e_%p_%t > /proc/sys/kernel/core_pattern'
now run your exception , you can got core file .
- maby you need search it :
sudo find / core_ | grep core_
how to fine exception code by core dump file ?
- I use vscode , fix
launch.json
, addcoreDumpPath
, refrence : https://code.visualstudio.com/docs/cpp/cpp-debug#_memory-dump-debugging