unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 688 forks source link

uwsgi provides false debugging information #2637

Open aizyuval opened 5 months ago

aizyuval commented 5 months ago

A problem with how uwsgi logs error messages, and therefore makes it harder to debug problems:

#define uwsgi_error(x) uwsgi_log("%s: %s [%s line %d]\n", x, strerror(errno), __FILE__, __LINE__);

This macro expands correctly, but the problem is that when uwsgi_error() is used under functions that are cross-refrenced, mainly in utils.c, uwsgi_error() takes the filename of the file where the function including it resides in, instead of where that function is called.

Example: uwsgi_malloc() is defined in utils.c, and calls uwsgi_error() if it can't allocate space. No matter where you call uwsgi_malloc, if an error happens - the filename that will be logged will always be 'utils.c' instead of where uwsgi_malloc() was originally called (say in some plugin)!

I have started writing a shell script that will: change uwsgi_error() definition, and respective definitions of functions that include it, and parents of these functions, to pass filename and line from the original call that will pass __FILE__ and __LINE__. That way uwsgi will always log the correct line and file that caused the issue!

This will introduce changes all throughout the project.

I think I will get around to it in a few days, If someone else has a better implementation for it, or is faster than me I'm therefore sharing this issue.