One day in a certain month, an engineer came to me and said: many users complained that the app was rolling back frequently. He thought the server was running normally and could not find the reason. Please help me.
Check the process and find that nginx access logs contain a large number of HTTP 504 err codes.
Tail-F/var/log/messages
A large number of similar error messages
Nginx [1234]: segfault at 0000000000000008 rip 000000000043edf8 RSP route 7fff34a21fa0 error 4
Segfault can only be used with GDB, which is also a benefit for Linux server. It is very troublesome to switch to the Microsoft platform.
The solution is divided into four steps:
-
The coredump file generated by the configuration system is simple.
Ulimit-
The first line is about the Core File Settings. By default, the coredump file is not generated.ulimit -c 1024Remember to use it after debugging is complete.ulimit -c 0Close, or your hard disk will soon be filled up
-
For GDB debugging, You Need To debug nginx to locate the source code, so you need to recompile an nginx
First, back up the existing nginx bin directory and conf directory.
Then print the original nginx compilation options
/Opt/nginx/sbin/nginx-V
Add -- With-Debug on this basis and make a copy again.
Find the compiled nginx in the $ {NGINX-SOURCE-DIR} $/objs directory and copy it to your nginx running directory. Remember not to make install because it will overwrite your nginx. conf file.
-
Run nginx again and wait for the core. xxx file to be generated. Generally, it is generated in the current directory.
-
Use GDB to load the coredump File
GDB -- core = core. xxx
GDB> where
It is easy to find the reason for nginx segfault: In an nginx modules we write ourselves, some parameters are not checked for the boundary, but after the external environment changes, the NULL pointer is accessed.
Ending:
-
Ulimit-C 0: Turn off coredump
-
After the code is changed, re-compile an nginx without debugging information.
From: http://lutaf.com/140.htm