Nginx modules & C includes

Jure Menart juremenart at gmail.com
Sat Aug 31 20:35:20 UTC 2013


Dear all,

I'm new to the Nginx project and I am just getting familiar with it. Let me
first thank to the contributors for the work they've put into to make the
project so nice.

I've observed very 'strange' behaviour and took me quite a lot time to find
the cause for it (not to understand it yet). Let me start in the beginning:
- I've been playing with Hello world examples of course and then started to
build bigger 'real' module.
- Suddenly I've got very unpredictable behaviour and seg. faults.
- I've stripped down my module back to real bare minimum - at the end I
just included one command which sends "Hello world" string back to the
client. The thing was still acting very strange: ngx_http_request_t seems
'unstable' - r->method with strange numbers, if I wanted to log in
r->connection->log I've got seg. fault, ... I'm fairly sure my test module
does not hot have any memory leaks because I am using only one static
string which is put to the output buffer.
- In the end I've removed the system C includes (sys/types.h, sys/stat.h,
unistd.h) and my simple example started to work again - I've tried few
times to add includes, put them before Nginx includes or after - it was
very repeatable and the module was stable if I either did not include or
include them after Nginx module:
For example:
<-- snip -->
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
<-- snip -->

Crashes my module, while:
<-- snip -->
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
<-- snip -->

Seems to work.

My question: Did anybody observed this behaviour? Obviously the system
includes can influence/change the includes in the Nginx. If this is known,
are there any special limitations while including system headers?
For sure this kind of behaviour is not nice and maybe it can be counted as
bug (or at least be documented).


Regards,
Jure Menart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130831/a931015b/attachment.html>


More information about the nginx-devel mailing list