2

1. Question

I run "crash_demo.run" by spawn-fcgi . How to collect core file .

2. Background & Environment

I'm exolore C++ Web Programming .

  1. web-server : nginx
  2. CGI(FastCGI) : fastcgipp 3.0
  3. 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 .
  4. My c++ application . (be called crash_demo) .

3. Step to reproduce exception

  1. crash_demo insert code throw "test exception str, check _core_ file" , build got crash_demo.run
  2. run nginx : sudo nginx -c my_nginx_custom.config
  3. ulimit -c unlimited
  4. run crash_demo.run by spawn-fcgi : spawn-fcgi -a 127.0.0.1 -p 9000 -f /path/crash_demo.run
  5. test the normal http request , and http request can be completed normally .
  6. test the crash_demo http request , got 5xx response .
    • The directory where crash_demo.run is located does not see the core file

My guess

  1. core file not generate .
  2. 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 :

  1. I read two webpage
    1. https://man7.org/linux/man-pages/man5/core.5.html
    2. https://zhuanlan.zhihu.com/p/240633280
  2. update my /proc/sys/kernel/core_pattern
    • core -> core_%e_%p_%t
  3. ulimit -c unlimited
  4. spawn-fcgi -a 127.0.0.1 -p 9000 -f /path/crash_demo.run
  5. sudo find / core_ | grep core_crash_demo
    • result /path/core_crash_demo._5080_1652169152

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 :

  1. how generate core dump file
  2. 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 :

  1. system limit core dump file size , we need unlimit it:
  • ulimit -a check limit / ulimit -c unlimited cancel limit
  1. fix /proc/sys/kernel/core_pattern
  • default value is core
  • fix it to -> core_%e_%p_%t mean core_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 ?

Tom
  • 333
  • 2
  • 8
  • I want get the crash core file . – Tom May 10 '22 at 03:26
  • 1
    [SO] is an English site. See [here](https://stackoverflow.com/help/article-guidelines#:~:text=Articles%20must%20be%20in%20the%20primary%20language%20of%20the%20target%20site%20that%20they%20accompany%20(currently%20English%2C%20since%20collectives%20%22accompany%22%20the%20main%20SO%20site%3B%20if%20there%27s%20ever%20a%20collective%20for%20another%20site%2C%20like%20the%20Russian%20SO%20site%2C%20it%20must%20be%20in%20the%20primary%20language%20of%20that%20site).) – sehe May 10 '22 at 04:49
  • @sehe yes , so i write one question twice by two language . – Tom May 10 '22 at 06:29

1 Answers1

1

This question is probably more for askubuntu.com or serverfault.stackexchange.com.

You likely need to configure core dump. Since we don't know the platform, I'm assuming likely a Linux. See e.g. core(5):

There are various circumstances in which a core dump file is not produced

In my experience what's required is setting a core pattern (/proc/sys/kernel/core_pattern)

sehe
  • 374,641
  • 47
  • 450
  • 633