On Sunday 01 September 2013 00:35:20 Jure Menart wrote: > 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). >
There is a commentary in the C++ example module (the only example that we have): http://trac.nginx.org/nginx/browser/nginx/src/misc/ngx_cpp_test_module.cpp#L19 // nginx header files should go before other, because they define 64-bit off_t wbr, Valentin V. Bartenev _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel